From: jacob Date: Wed, 22 Dec 2004 23:17:02 +0000 (+0000) Subject: Fix potential access of freed data (only if we couldn't create the X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/commitdiff_plain/2d3f15fac22aad183784edf0a378e7c4229cd238 Fix potential access of freed data (only if we couldn't create the second of two registry keys, so pretty unlikely). git-svn-id: svn://svn.tartarus.org/sgt/putty@5021 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/windows/winstore.c b/windows/winstore.c index f454f172..743283f6 100644 --- a/windows/winstore.c +++ b/windows/winstore.c @@ -82,13 +82,14 @@ void *open_settings_w(const char *sessionname, char **errmsg) return NULL; } ret = RegCreateKey(subkey1, p, &sesskey); - sfree(p); RegCloseKey(subkey1); if (ret != ERROR_SUCCESS) { *errmsg = dupprintf("Unable to create registry key\n" "HKEY_CURRENT_USER\\%s\\%s", puttystr, p); + sfree(p); return NULL; } + sfree(p); return (void *) sesskey; }