1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Fix assertion failure in wprefs() when the list is zero-length. Breaks

any session-save operation in PuTTYtel due to the empty GSS list.

[originally from svn r9276]
This commit is contained in:
Simon Tatham 2011-09-13 07:35:14 +00:00
parent 8e4df14ee7
commit 9da44eeb26

View File

@ -382,11 +382,11 @@ static void wprefs(void *sesskey, char *name,
const char *s = val2key(mapping, nvals,
conf_get_int_int(conf, primary, i));
if (s) {
maxlen += 1 + strlen(s);
maxlen += (maxlen > 0 ? 1 : 0) + strlen(s);
}
}
buf = snewn(maxlen, char);
buf = snewn(maxlen + 1, char);
p = buf;
for (i = 0; i < nvals; i++) {
@ -397,7 +397,8 @@ static void wprefs(void *sesskey, char *name,
}
}
assert(p - buf == maxlen - 1); /* maxlen counted the NUL */
assert(p - buf == maxlen);
*p = '\0';
write_setting_s(sesskey, name, buf);