Skip to content

Commit 8a0b2cd

Browse files
loadHashTable(): fix memory leak in error code path (#6661)
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52111
1 parent 41a8871 commit 8a0b2cd

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

mapfile.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2171,7 +2171,6 @@ static void writeExpression(FILE *stream, int indent, const char *name, expressi
21712171

21722172
int loadHashTable(hashTableObj *ptable)
21732173
{
2174-
char *key=NULL, *data=NULL;
21752174
assert(ptable);
21762175

21772176
for(;;) {
@@ -2182,14 +2181,19 @@ int loadHashTable(hashTableObj *ptable)
21822181
case(END):
21832182
return(MS_SUCCESS);
21842183
case(MS_STRING):
2185-
key = msStrdup(msyystring_buffer); /* the key is *always* a string */
2186-
if(getString(&data) == MS_FAILURE) return(MS_FAILURE);
2184+
{
2185+
char* data = NULL;
2186+
char* key = msStrdup(msyystring_buffer); /* the key is *always* a string */
2187+
if(getString(&data) == MS_FAILURE) {
2188+
free(key);
2189+
return(MS_FAILURE);
2190+
}
21872191
msInsertHashTable(ptable, key, data);
21882192

21892193
free(key);
21902194
free(data);
2191-
data=NULL;
21922195
break;
2196+
}
21932197
default:
21942198
msSetError(MS_IDENTERR, "Parsing error near (%s):(line %d)", "loadHashTable()", msyystring_buffer, msyylineno );
21952199
return(MS_FAILURE);

0 commit comments

Comments
 (0)