]> granicus.if.org Git - libevent/commitdiff
If no evdns request can be launched, return NULL, not a handle
authorNick Mathewson <nickm@torproject.org>
Tue, 18 May 2010 21:27:06 +0000 (17:27 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 18 May 2010 21:27:06 +0000 (17:27 -0400)
Some of our evdns code was willing to return an evdns_request with
handle->current_req set to NULL.  Really, those cases should just
return NULL.

evdns.c

diff --git a/evdns.c b/evdns.c
index 7b2b72cc126bb31466801274c6cd7e373d4c91b4..309b466ebf60684a112f8d7831f41817f018828a 100644 (file)
--- a/evdns.c
+++ b/evdns.c
@@ -2692,8 +2692,12 @@ evdns_base_resolve_ipv4(struct evdns_base *base, const char *name, int flags,
                if (req)
                        request_submit(req);
        } else {
-               req = search_request_new(base, handle, TYPE_A, name, flags,
-                                        callback, ptr);
+               search_request_new(base, handle, TYPE_A, name, flags,
+                   callback, ptr);
+       }
+       if (handle->current_req == NULL) {
+               mm_free(handle);
+               handle = NULL;
        }
        EVDNS_UNLOCK(base);
        return handle;
@@ -2726,8 +2730,12 @@ evdns_base_resolve_ipv6(struct evdns_base *base,
                if (req)
                        request_submit(req);
        } else {
-               req = search_request_new(base, handle, TYPE_AAAA, name, flags,
-                                        callback, ptr);
+               search_request_new(base, handle, TYPE_AAAA, name, flags,
+                   callback, ptr);
+       }
+       if (handle->current_req == NULL) {
+               mm_free(handle);
+               handle = NULL;
        }
        EVDNS_UNLOCK(base);
        return handle;
@@ -2760,6 +2768,10 @@ evdns_base_resolve_reverse(struct evdns_base *base, const struct in_addr *in, in
        req = request_new(base, handle, TYPE_PTR, buf, flags, callback, ptr);
        if (req)
                request_submit(req);
+       if (handle->current_req == NULL) {
+               mm_free(handle);
+               handle = NULL;
+       }
        EVDNS_UNLOCK(base);
        return (handle);
 }
@@ -2796,6 +2808,10 @@ evdns_base_resolve_reverse_ipv6(struct evdns_base *base, const struct in6_addr *
        req = request_new(base, handle, TYPE_PTR, buf, flags, callback, ptr);
        if (req)
                request_submit(req);
+       if (handle->current_req == NULL) {
+               mm_free(handle);
+               handle = NULL;
+       }
        EVDNS_UNLOCK(base);
        return (handle);
 }