]> granicus.if.org Git - libevent/commitdiff
evdns: do not check server_req twice
authorAzat Khuzhin <azat@libevent.org>
Sun, 31 Mar 2019 23:41:17 +0000 (02:41 +0300)
committerAzat Khuzhin <azat@libevent.org>
Sun, 31 Mar 2019 23:42:30 +0000 (02:42 +0300)
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.
"

evdns.c

diff --git a/evdns.c b/evdns.c
index 3cf6ef0955a87fbfa26de7434b35cd8e933f3201..db25ad54a3f08eab4244abf12ab10471e4d0639c 100644 (file)
--- 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