Permalink
Browse files

fix memory leak on hashTableSubstituteString (#5325)

  • Loading branch information...
1 parent 66309ee commit fd55fd35c9766f80ffe8095e96452166c832b479 @tbonfort tbonfort committed Sep 15, 2016
Showing with 4 additions and 2 deletions.
  1. +4 −2 mapfile.c
View
@@ -6972,12 +6972,14 @@ int msUpdateMapFromURL(mapObj *map, char *variable, char *string)
}
static void hashTableSubstituteString(hashTableObj *hash, const char *from, const char *to) {
- const char *key, *val;
+ const char *key, *val, *new_val;
key = msFirstKeyFromHashTable(hash);
while(key != NULL) {
val = msLookupHashTable(hash, key);
if(strcasestr(val, from)) {
- msInsertHashTable(hash, key, msCaseReplaceSubstring(msStrdup(val), from, to));
+ new_val = msCaseReplaceSubstring(msStrdup(val), from, to);
+ msInsertHashTable(hash, key, new_val);
+ msFree(new_val);
}
key = msNextKeyFromHashTable(hash, key);
}

0 comments on commit fd55fd3

Please sign in to comment.