Avoid memory leak in error messages in control.c (not in any tor)

This commit is contained in:
Nick Mathewson 2015-04-23 09:26:31 -04:00
parent 43a8457b56
commit f5fa6ac534

View File

@ -1716,13 +1716,11 @@ getinfo_helper_dir(control_connection_t *control_conn,
SMARTLIST_FOREACH(sl, char *, c, tor_free(c)); SMARTLIST_FOREACH(sl, char *, c, tor_free(c));
smartlist_free(sl); smartlist_free(sl);
} else if (!strcmpstart(question, "hs/client/desc/id/")) { } else if (!strcmpstart(question, "hs/client/desc/id/")) {
char *msg;
rend_cache_entry_t *e = NULL; rend_cache_entry_t *e = NULL;
question += strlen("hs/client/desc/id/"); question += strlen("hs/client/desc/id/");
if (strlen(question) != REND_SERVICE_ID_LEN_BASE32) { if (strlen(question) != REND_SERVICE_ID_LEN_BASE32) {
tor_asprintf(&msg, "\"%s\" invalid address.", question); *errmsg = "Invalid address";
*errmsg = msg;
return -1; return -1;
} }
@ -1730,8 +1728,7 @@ getinfo_helper_dir(control_connection_t *control_conn,
/* Descriptor found in cache */ /* Descriptor found in cache */
*answer = tor_strdup(e->desc); *answer = tor_strdup(e->desc);
} else { } else {
tor_asprintf(&msg, "\"%s\" not found in cache.", question); *errmsg = "Not found in cache";
*errmsg = msg;
return -1; return -1;
} }
} else if (!strcmpstart(question, "md/id/")) { } else if (!strcmpstart(question, "md/id/")) {