]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Thanks to Hans-Juergen Petrich for spotting this tiny memory leak:
authorSimon Tatham <anakin@pobox.com>
Sun, 17 Nov 2002 15:06:16 +0000 (15:06 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 17 Nov 2002 15:06:16 +0000 (15:06 +0000)
`otherbuf' should still be freed even if the RegEnumKey function
that was supposed to fill it with data failed. While I'm at it, also
remove the redundant check for its non-NULL-ness (what's the point
of having a malloc wrapper that dies rather than return NULL if you
then waste effort checking its return value for NULL _anyway_, eh?).

[originally from svn r2217]

winstore.c

index d480079669c936e279ac9820a988a1b0f35d162f..bc7bb5b1853b7446b1c54c3cdfeef7fba0d5ee6d 100644 (file)
@@ -198,14 +198,14 @@ char *enum_settings_next(void *handle, char *buffer, int buflen)
     struct enumsettings *e = (struct enumsettings *) handle;
     char *otherbuf;
     otherbuf = smalloc(3 * buflen);
-    if (otherbuf && RegEnumKey(e->key, e->i++, otherbuf,
-                              3 * buflen) == ERROR_SUCCESS) {
+    if (RegEnumKey(e->key, e->i++, otherbuf, 3 * buflen) == ERROR_SUCCESS) {
        unmungestr(otherbuf, buffer, buflen);
        sfree(otherbuf);
        return buffer;
-    } else
+    } else {
+       sfree(otherbuf);
        return NULL;
-
+    }
 }
 
 void enum_settings_finish(void *handle)