1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-14 01:27:35 -05:00

Make memory management uniform: _everything_ now goes through the

smalloc() macros and thence to the safemalloc() functions in misc.c.
This should allow me to plug in a debugging allocator and track
memory leaks and segfaults and things.

[originally from svn r818]
This commit is contained in:
Simon Tatham
2000-12-12 10:33:13 +00:00
parent 8eca227b92
commit d5240d4157
20 changed files with 201 additions and 183 deletions

View File

@ -238,7 +238,7 @@ static void add_keyfile(char *filename) {
needs_pass = rsakey_encrypted(filename, &comment);
attempts = 0;
key = malloc(sizeof(*key));
key = smalloc(sizeof(*key));
pps.passphrase = passphrase;
pps.comment = comment;
do {
@ -248,8 +248,8 @@ static void add_keyfile(char *filename) {
NULL, PassphraseProc,
(LPARAM)&pps);
if (!dlgret) {
if (comment) free(comment);
free(key);
if (comment) sfree(comment);
sfree(key);
return; /* operation cancelled */
}
} else
@ -257,15 +257,15 @@ static void add_keyfile(char *filename) {
ret = loadrsakey(filename, key, NULL, passphrase);
attempts++;
} while (ret == -1);
if (comment) free(comment);
if (comment) sfree(comment);
if (ret == 0) {
MessageBox(NULL, "Couldn't load private key.", APPNAME,
MB_OK | MB_ICONERROR);
free(key);
sfree(key);
return;
}
if (add234(rsakeys, key) != key)
free(key); /* already present, don't waste RAM */
sfree(key); /* already present, don't waste RAM */
}
/*
@ -382,14 +382,14 @@ static void answer_msg(void *msg) {
{
struct RSAKey *key;
char *comment;
key = malloc(sizeof(struct RSAKey));
key = smalloc(sizeof(struct RSAKey));
memset(key, 0, sizeof(key));
p += makekey(p, key, NULL, 1);
p += makeprivate(p, key);
p += ssh1_read_bignum(p, NULL); /* p^-1 mod q */
p += ssh1_read_bignum(p, NULL); /* p */
p += ssh1_read_bignum(p, NULL); /* q */
comment = malloc(GET_32BIT(p));
comment = smalloc(GET_32BIT(p));
if (comment) {
memcpy(comment, p+4, GET_32BIT(p));
key->comment = comment;
@ -401,7 +401,7 @@ static void answer_msg(void *msg) {
ret[4] = SSH_AGENT_SUCCESS;
} else {
freersakey(key);
free(key);
sfree(key);
}
}
break;