ecere/sys/GlobalAppSettings: Fixed global settings issues on Linux
authorJerome St-Louis <jerome@ecere.com>
Fri, 24 Oct 2014 07:01:19 +0000 (03:01 -0400)
committerJerome St-Louis <jerome@ecere.com>
Fri, 24 Oct 2014 08:00:14 +0000 (04:00 -0400)
- There was 3 major problems causing memory corruption, hangs on exit, crashes on startup, settings not saving

ecere/src/sys/GlobalAppSettings.ec

index bf9a9f5..f44efe9 100644 (file)
@@ -252,7 +252,6 @@ private:
          {
             strcpy(buffer, "/etc/");
             path = GetFilePath(buffer, extension, create, false, false);
-            delete buffer;
             break;
          }
 #endif
@@ -273,8 +272,12 @@ private:
          {
             if(dotPrefix)
             {
-               PathCatSlash(location, ".");
-               strcat(location, settingsDirectory);
+               int len = strlen(settingsDirectory);
+               String s = new char[len + 2];
+               s[0] = '.';
+               memcpy(s + 1, settingsDirectory, len + 1);
+               PathCatSlash(location, s);
+               delete s;
             }
             else
                PathCatSlash(location, settingsDirectory);
@@ -284,7 +287,7 @@ private:
          }
          if(attribs.isDirectory || attribs.isDrive)
          {
-            char * name = new char[strlen(settingsName) + strlen(extension) + 2];
+            char * name = new char[strlen(settingsName) + strlen(extension) + 4];
             if(dotPrefix && !settingsDirectory)
             {
                strcpy(name, ".");