]> granicus.if.org Git - libevent/commitdiff
r19679@catbus: nickm | 2008-05-11 20:56:12 -0400
authorNick Mathewson <nickm@torproject.org>
Mon, 12 May 2008 00:56:19 +0000 (00:56 +0000)
committerNick Mathewson <nickm@torproject.org>
Mon, 12 May 2008 00:56:19 +0000 (00:56 +0000)
 Windows does not have alloca().

svn:r810

http.c

diff --git a/http.c b/http.c
index 6e19674904d4831e8feea484347efe6539dfc1ef..b8927235d1b23a8d2f0e63b4979a57951b50d53f 100644 (file)
--- a/http.c
+++ b/http.c
@@ -1901,8 +1901,7 @@ evhttp_dispatch_callback(struct httpcbq *callbacks, struct evhttp_request *req)
                ++p;
        offset = (size_t)(p - req->uri);
 
-       /* allocate the rewritten version on the stack */
-       if ((translated = alloca(offset + 1)) == NULL)
+       if ((translated = mm_malloc(offset + 1)) == NULL)
                return (NULL);
        offset = evhttp_decode_uri_internal(req->uri, offset, translated);
 
@@ -1911,10 +1910,13 @@ evhttp_dispatch_callback(struct httpcbq *callbacks, struct evhttp_request *req)
                res = ((strncmp(cb->what, translated, offset) == 0) &&
                    (cb->what[offset] == '\0'));
 
-               if (res)
+               if (res) {
+                       mm_free(translated);
                        return (cb);
+               }
        }
 
+       mm_free(translated);
        return (NULL);
 }