From 78f1ca1d6fbf69326beb2dd8bd27798012f0da55 Mon Sep 17 00:00:00 2001 From: Fatbag Date: Fri, 25 May 2012 16:44:44 -0500 Subject: [PATCH] Fixed Pascal string reading in GLOB chunks --- Libraries/FileHandler/iff/glob.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Libraries/FileHandler/iff/glob.c b/Libraries/FileHandler/iff/glob.c index 9353dab..090ce23 100644 --- a/Libraries/FileHandler/iff/glob.c +++ b/Libraries/FileHandler/iff/glob.c @@ -23,12 +23,15 @@ int iff_parse_glob(IFFChunk * ChunkInfo, const uint8_t * Buffer){ unsigned Size = ChunkInfo->Size - 76; unsigned length; - if(Size == 0) return 0; + if(Size == 0){ + *string = NULL; + return 0; + } /* Try reading as a C string */ for(length=0; length != Size && Buffer[length] && Buffer[length] != 0xA3; length++); - if(length != Size){ + if(length != Size && !Buffer[length] /* null character; in these strings, 0xA3 doesn't count */){ if(length > 0){ *string = malloc(length+1); if(*string == NULL) return 0;