From: Azat Khuzhin Date: Sun, 31 Mar 2019 23:41:17 +0000 (+0300) Subject: evdns: do not check server_req twice X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=991f0ed3d86ffca0c017ab83cd239289912bdaad;p=libevent evdns: do not check server_req twice Reported by µchex: "In evdns.c, pointer server_req is null checked on line 1289 after it is dereferenced above. Since server_req was already null checked above on line 1243, there is no risk of crashing and the only bug is the redundant null check (and indentation) on line 1289. " --- diff --git a/evdns.c b/evdns.c index 3cf6ef09..db25ad54 100644 --- a/evdns.c +++ b/evdns.c @@ -1299,14 +1299,12 @@ request_parse(u8 *packet, int length, struct evdns_server_port *port, struct soc return 0; err: - if (server_req) { - if (server_req->base.questions) { - for (i = 0; i < server_req->base.nquestions; ++i) - mm_free(server_req->base.questions[i]); - mm_free(server_req->base.questions); - } - mm_free(server_req); + if (server_req->base.questions) { + for (i = 0; i < server_req->base.nquestions; ++i) + mm_free(server_req->base.questions[i]); + mm_free(server_req->base.questions); } + mm_free(server_req); return -1; #undef SKIP_NAME