Code

http.c: set slot callback members to NULL when releasing object
authorTay Ray Chuan <rctay89@gmail.com>
Wed, 26 Aug 2009 12:20:53 +0000 (20:20 +0800)
committerJunio C Hamano <gitster@pobox.com>
Sat, 29 Aug 2009 02:24:43 +0000 (19:24 -0700)
Set the members callback_func and callback_data of freq->slot to NULL
when releasing a http_object_request. release_active_slot() is also
invoked on the slot to remove the curl handle associated with the slot
from the multi stack (CURLM *curlm in http.c).

These prevent the callback function and data from being used in http
methods (like http.c::finish_active_slot()) after a
http_object_request has been free'd.

Noticed by Ali Polatel, who later tested this patch to verify that it
fixes the problem he saw; Dscho helped to identify the problem spot.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
http.c

diff --git a/http.c b/http.c
index a2720d576d72e456b038444050f5b8de9d25d792..1ae19e070dfd138a6c6729d7725da65c41c186eb 100644 (file)
--- a/http.c
+++ b/http.c
@@ -1285,5 +1285,10 @@ void release_http_object_request(struct http_object_request *freq)
                free(freq->url);
                freq->url = NULL;
        }
-       freq->slot = NULL;
+       if (freq->slot != NULL) {
+               freq->slot->callback_func = NULL;
+               freq->slot->callback_data = NULL;
+               release_active_slot(freq->slot);
+               freq->slot = NULL;
+       }
 }