From 60371ab36cd27a18236d969f0ebdbd2aa73b1705 Mon Sep 17 00:00:00 2001 From: simon Date: Sun, 17 Nov 2002 15:06:16 +0000 Subject: [PATCH] Thanks to Hans-Juergen Petrich for spotting this tiny memory leak: `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?). git-svn-id: svn://svn.tartarus.org/sgt/putty@2217 cda61777-01e9-0310-a592-d414129be87e --- winstore.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/winstore.c b/winstore.c index d4800796..bc7bb5b1 100644 --- a/winstore.c +++ b/winstore.c @@ -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) -- 2.11.0