Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2016-09-02 21:54:03 +0300
committerLluis Sanchez <lluis@xamarin.com>2016-09-02 21:54:03 +0300
commitd16761db3385aef3a138486099091c7678d3851f (patch)
treec477db0e59033c9cfe22e41dc886001ae21eeb6f
parentd1db2254f99a752f1c19adfac7ca31a99486529b (diff)
Fix crash when calculating absolute path
Calculation of the size of the resulting string was wrong. Fixes bug #42376 - Xamarin Studio 6.0 introduced crash while loading our solution.
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs14
1 files changed, 11 insertions, 3 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs
index cac183b079..38907b8523 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FileService.cs
@@ -454,7 +454,7 @@ namespace MonoDevelop.Core
// handle case a: some/path b: some/path/deeper...
if (a >= aEnd) {
if (IsSeparator (*b)) {
- lastStartA = a + 1;
+ lastStartA = aEnd;
lastStartB = b;
}
}
@@ -466,7 +466,14 @@ namespace MonoDevelop.Core
goUpCount++;
lastStartB++;
}
- var size = goUpCount * 2 + goUpCount + aEnd - lastStartA;
+ int remainingPathLength = (int)(aEnd - lastStartA);
+ var size = goUpCount * 2 + goUpCount;
+ if (remainingPathLength > 0) {
+ if (goUpCount > 0)
+ size++;
+ size += remainingPathLength;
+ }
+
var result = new char [size];
fixed (char* rPtr = result) {
// go paths up
@@ -474,7 +481,8 @@ namespace MonoDevelop.Core
for (int i = 0; i < goUpCount; i++) {
*(r++) = '.';
*(r++) = '.';
- *(r++) = Path.DirectorySeparatorChar;
+ if (i != goUpCount - 1 || remainingPathLength > 0) // If there is no remaining path, there is no need for a trailing slash
+ *(r++) = Path.DirectorySeparatorChar;
}
// copy the remaining absulute path
while (lastStartA < aEnd)