From 8a990e7dd68c08a1a48349d99cd0979c28595ee2 Mon Sep 17 00:00:00 2001 From: Art Yerkes Date: Sat, 19 Apr 2008 23:16:39 +0000 Subject: [PATCH] Fix two very small bugs found by running this code in valgrind. svn path=/trunk/; revision=33041 --- reactos/boot/freeldr/freeldr/inifile/inifile.c | 3 ++- reactos/boot/freeldr/freeldr/inifile/parse.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/inifile/inifile.c b/reactos/boot/freeldr/freeldr/inifile/inifile.c index 038c0e764a8..63b412b78e7 100644 --- a/reactos/boot/freeldr/freeldr/inifile/inifile.c +++ b/reactos/boot/freeldr/freeldr/inifile/inifile.c @@ -34,7 +34,8 @@ BOOLEAN IniOpenSection(PCSTR SectionName, ULONG* SectionId) if (_stricmp(SectionName, Section->SectionName) == 0) { // We found it - *SectionId = (ULONG)Section; + if (SectionId) + *SectionId = (ULONG)Section; DbgPrint((DPRINT_INIFILE, "IniOpenSection() Found it! SectionId = 0x%x\n", SectionId)); return TRUE; } diff --git a/reactos/boot/freeldr/freeldr/inifile/parse.c b/reactos/boot/freeldr/freeldr/inifile/parse.c index 572cb62ed9b..531125a9229 100644 --- a/reactos/boot/freeldr/freeldr/inifile/parse.c +++ b/reactos/boot/freeldr/freeldr/inifile/parse.c @@ -232,9 +232,9 @@ ULONG IniGetNextLine(PCHAR IniFileData, ULONG IniFileSize, PCHAR Buffer, ULONG B Buffer[Idx] = '\0'; // Get rid of newline & linefeed characters (if any) - if((Buffer[strlen(Buffer)-1] == '\n') || (Buffer[strlen(Buffer)-1] == '\r')) + if(strlen(Buffer) && ((Buffer[strlen(Buffer)-1] == '\n') || (Buffer[strlen(Buffer)-1] == '\r'))) Buffer[strlen(Buffer)-1] = '\0'; - if((Buffer[strlen(Buffer)-1] == '\n') || (Buffer[strlen(Buffer)-1] == '\r')) + if(strlen(Buffer) && ((Buffer[strlen(Buffer)-1] == '\n') || (Buffer[strlen(Buffer)-1] == '\r'))) Buffer[strlen(Buffer)-1] = '\0'; // Send back new offset