]> granicus.if.org Git - libevent/commitdiff
Check if the `evhttp_new_object' function in `http.c' returns NULL.
authorMansour Moufid <mansourmoufid@gmail.com>
Fri, 27 May 2011 22:40:31 +0000 (18:40 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 8 Jun 2011 20:46:21 +0000 (16:46 -0400)
http.c

diff --git a/http.c b/http.c
index b97485f65e00ebd75a76a41bc6652be8405cde1a..a2bc570feb9bc835e5aacf7975d28ff5988c4449 100644 (file)
--- a/http.c
+++ b/http.c
@@ -3203,8 +3203,11 @@ evhttp_new_object(void)
 struct evhttp *
 evhttp_new(struct event_base *base)
 {
-       struct evhttp *http = evhttp_new_object();
+       struct evhttp *http = NULL;
 
+       http = evhttp_new_object();
+       if (http == NULL)
+               return (NULL);
        http->base = base;
 
        return (http);
@@ -3217,8 +3220,11 @@ evhttp_new(struct event_base *base)
 struct evhttp *
 evhttp_start(const char *address, unsigned short port)
 {
-       struct evhttp *http = evhttp_new_object();
+       struct evhttp *http = NULL;
 
+       http = evhttp_new_object();
+       if (http == NULL)
+               return (NULL);
        if (evhttp_bind_socket(http, address, port) == -1) {
                mm_free(http);
                return (NULL);