[USETUP]: Do not append an extra NULL-terminator when updating freeldr.ini
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 9 Jan 2016 11:39:56 +0000 (11:39 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 9 Jan 2016 11:39:56 +0000 (11:39 +0000)
svn path=/trunk/; revision=70558

reactos/base/setup/usetup/inicache.c

index 955712a..0043e9d 100644 (file)
@@ -537,7 +537,7 @@ IniCacheLoad(
 
     DPRINT("File size: %lu\n", FileLength);
 
 
     DPRINT("File size: %lu\n", FileLength);
 
-    /* Allocate file buffer */
+    /* Allocate file buffer with NULL-terminator */
     FileBuffer = (CHAR*)RtlAllocateHeap(ProcessHeap,
                                         0,
                                         FileLength + 1);
     FileBuffer = (CHAR*)RtlAllocateHeap(ProcessHeap,
                                         0,
                                         FileLength + 1);
@@ -560,7 +560,7 @@ IniCacheLoad(
                         &FileOffset,
                         NULL);
 
                         &FileOffset,
                         NULL);
 
-    /* Append string terminator */
+    /* Append NULL-terminator */
     FileBuffer[FileLength] = 0;
 
     NtClose(FileHandle);
     FileBuffer[FileLength] = 0;
 
     NtClose(FileHandle);
@@ -971,16 +971,15 @@ IniCacheSave(
 
         Section = Section->Next;
         if (Section != NULL)
 
         Section = Section->Next;
         if (Section != NULL)
-            BufferSize += 2; /* extra "\r\n" at end of each section */
+            BufferSize += 2; /* Extra "\r\n" at end of each section */
     }
     }
-    BufferSize++; /* Null-terminator */
 
     DPRINT("BufferSize: %lu\n", BufferSize);
 
 
     DPRINT("BufferSize: %lu\n", BufferSize);
 
-    /* Allocate file buffer */
+    /* Allocate file buffer with NULL-terminator */
     Buffer = (CHAR*)RtlAllocateHeap(ProcessHeap,
                                     HEAP_ZERO_MEMORY,
     Buffer = (CHAR*)RtlAllocateHeap(ProcessHeap,
                                     HEAP_ZERO_MEMORY,
-                                    BufferSize);
+                                    BufferSize + 1);
     if (Buffer == NULL)
     {
         DPRINT1("RtlAllocateHeap() failed\n");
     if (Buffer == NULL)
     {
         DPRINT1("RtlAllocateHeap() failed\n");