Fix potential access of freed data (only if we couldn't create the
authorjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Wed, 22 Dec 2004 23:17:02 +0000 (23:17 +0000)
committerjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Wed, 22 Dec 2004 23:17:02 +0000 (23:17 +0000)
second of two registry keys, so pretty unlikely).

git-svn-id: svn://svn.tartarus.org/sgt/putty@5021 cda61777-01e9-0310-a592-d414129be87e

windows/winstore.c

index f454f17..743283f 100644 (file)
@@ -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;
 }