[or-cvs] Never call free() on tor_malloc()d memory. This is unlikely...
Nick Mathewson
nickm at seul.org
Fri Sep 30 20:48:00 UTC 2005
Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv4911/src/common
Modified Files:
aes.c container.c crypto.c tortls.c
Log Message:
Never call free() on tor_malloc()d memory. This is unlikely to be our current leak, but it may help dmalloc work.
Index: aes.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/aes.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- aes.c 30 Sep 2005 01:09:52 -0000 1.27
+++ aes.c 30 Sep 2005 20:47:58 -0000 1.28
@@ -157,7 +157,7 @@
{
assert(cipher);
memset(cipher, 0, sizeof(cipher));
- free(cipher);
+ tor_free(cipher);
}
/** Encrypt <b>len</b> bytes from <b>input</b>, storing the result in
Index: container.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/container.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- container.c 30 Sep 2005 01:39:24 -0000 1.42
+++ container.c 30 Sep 2005 20:47:58 -0000 1.43
@@ -58,8 +58,8 @@
void
smartlist_free(smartlist_t *sl)
{
- free(sl->list);
- free(sl);
+ tor_free(sl->list);
+ tor_free(sl);
}
/** Change the capacity of the smartlist to <b>n</b>, so that we can grow
Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/crypto.c,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -d -r1.159 -r1.160
--- crypto.c 30 Sep 2005 01:39:24 -0000 1.159
+++ crypto.c 30 Sep 2005 20:47:58 -0000 1.160
@@ -323,7 +323,7 @@
if (env->key)
RSA_free(env->key);
- free(env);
+ tor_free(env);
}
/** Create a new symmetric cipher for a given key and encryption flag
@@ -561,7 +561,7 @@
s[len]='\0';
r = write_str_to_file(fname, s, 0);
BIO_free(bio);
- free(s);
+ tor_free(s);
return r;
}
@@ -1032,14 +1032,14 @@
len = i2d_RSAPublicKey(pk->key, &bufp);
if (len < 0) {
crypto_log_errors(LOG_WARN,"encoding public key");
- free(buf);
+ tor_free(buf);
return -1;
}
if (crypto_digest(digest_out, (char*)buf, len) < 0) {
- free(buf);
+ tor_free(buf);
return -1;
}
- free(buf);
+ tor_free(buf);
return 0;
}
@@ -1367,7 +1367,7 @@
err:
crypto_log_errors(LOG_WARN, "creating DH object");
if (res && res->dh) DH_free(res->dh); /* frees p and g too */
- if (res) free(res);
+ if (res) tor_free(res);
return NULL;
}
@@ -1564,7 +1564,7 @@
tor_assert(dh);
tor_assert(dh->dh);
DH_free(dh->dh);
- free(dh);
+ tor_free(dh);
}
/* random numbers */
Index: tortls.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/tortls.c,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -d -r1.103 -r1.104
--- tortls.c 30 Sep 2005 01:09:52 -0000 1.103
+++ tortls.c 30 Sep 2005 20:47:58 -0000 1.104
@@ -408,7 +408,7 @@
if (result && result->client_only_ctx)
SSL_CTX_free(result->client_only_ctx);
if (result)
- free(result);
+ tor_free(result);
if (cert)
X509_free(cert);
if (idcert)
More information about the tor-commits
mailing list