1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48:00 +00:00

Fix memory leak in rsa_ssh1_savekey.

The strbuf containing the data of the output key file was never freed.
This commit is contained in:
Simon Tatham 2019-01-29 20:11:46 +00:00
parent 6e7df89316
commit 85b1916ca6

View File

@ -371,13 +371,14 @@ bool rsa_ssh1_savekey(const Filename *filename, RSAKey *key,
* Done. Write the result to the file. * Done. Write the result to the file.
*/ */
fp = f_open(filename, "wb", true); fp = f_open(filename, "wb", true);
bool ret = false;
if (fp) { if (fp) {
bool ret = (fwrite(buf->u, 1, buf->len, fp) == (size_t) (buf->len)); ret = (fwrite(buf->u, 1, buf->len, fp) == (size_t) (buf->len));
if (fclose(fp)) if (fclose(fp))
ret = false; ret = false;
return ret; }
} else strbuf_free(buf);
return false; return ret;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------