mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-05-28 23:34:49 -05:00
Windows open_settings_r: return NULL for a nonexistent session.
Previously, we returned a valid settings_r containing a null HKEY. That didn't actually cause trouble (I think all the registry API functions must have spotted the null HKEY and returned a clean error code instead of crashing), but it means the caller can't tell if the session really existed or not. Now we return NULL in that situation, and close_settings_r avoids crashing if we pass the NULL to it later.
This commit is contained in:
parent
1db5001260
commit
69b216c116
@ -113,6 +113,9 @@ settings_r *open_settings_r(const char *sessionname)
|
||||
|
||||
strbuf_free(sb);
|
||||
|
||||
if (!sesskey)
|
||||
return NULL;
|
||||
|
||||
settings_r *toret = snew(settings_r);
|
||||
toret->sesskey = sesskey;
|
||||
return toret;
|
||||
@ -237,8 +240,10 @@ void write_setting_filename(settings_w *handle,
|
||||
|
||||
void close_settings_r(settings_r *handle)
|
||||
{
|
||||
RegCloseKey(handle->sesskey);
|
||||
sfree(handle);
|
||||
if (handle) {
|
||||
RegCloseKey(handle->sesskey);
|
||||
sfree(handle);
|
||||
}
|
||||
}
|
||||
|
||||
void del_settings(const char *sessionname)
|
||||
|
Loading…
x
Reference in New Issue
Block a user