summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-12-05 01:29:59 +0000
committerNick Mathewson <nickm@torproject.org>2008-12-05 01:29:59 +0000
commit2be52151816dbec0d9548362775c9bc5de46372e (patch)
tree8ba2236245e77b681f42684b70bc866c548035d6 /src/common
parentea975ddeee9a33fd410afedfd15c10159a2aa834 (diff)
downloadtor-2be52151816dbec0d9548362775c9bc5de46372e.tar.gz
tor-2be52151816dbec0d9548362775c9bc5de46372e.zip
Fix a hard-to-trigger memory leak in log_credential status. Found by Coverity scan. CID 349.
svn:r17484
Diffstat (limited to 'src/common')
-rw-r--r--src/common/compat.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index fcc57f60db..9ce5885dc1 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -1049,17 +1049,17 @@ log_credential_status(void)
strerror(errno));
return -1;
} else {
- int i;
+ int i, retval = 0;
char *strgid;
char *s = NULL;
- int formatting_error = 0;
smartlist_t *elts = smartlist_create();
for (i = 0; i<ngids; i++) {
strgid = tor_malloc(11);
- if (tor_snprintf(strgid, 11, "%u", (unsigned)sup_gids[i]) == -1) {
+ if (tor_snprintf(strgid, 11, "%u", (unsigned)sup_gids[i]) < 0) {
log_warn(LD_GENERAL, "Error printing supplementary GIDs");
- formatting_error = 1;
+ tor_free(strgid);
+ retval = -1;
goto error;
}
smartlist_add(elts, strgid);
@@ -1077,8 +1077,7 @@ log_credential_status(void)
});
smartlist_free(elts);
- if (formatting_error)
- return -1;
+ return retval;
}
#endif