http-push: free transfer_request dest field
When we issue a PUT request, we store the destination in the "dest" field by detaching from a strbuf. But we never free the result, causing a leak. We can address this in the release_request() function. But note that we also need to initialize it to NULL, as most other request types do not set it at all. Curiously there are _two_ functions to initialize a transfer_request struct. Adding the initialization only to add_fetch_request() seems to be enough for t5540, but I won't pretend to understand why. Rather than just adding "request->dest = NULL" in both spots, let's zero the whole struct. That addresses this problem, as well as any future ones (and it can't possibly hurt, as by definition we'd be hitting uninitialized memory previously). This fixes several leaks noticed by t5540. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
747a71019c
commit
7d3c71ddbf
10
http-push.c
10
http-push.c
@@ -514,6 +514,7 @@ static void release_request(struct transfer_request *request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(request->url);
|
free(request->url);
|
||||||
|
free(request->dest);
|
||||||
free(request);
|
free(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -651,11 +652,8 @@ static void add_fetch_request(struct object *obj)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
obj->flags |= FETCHING;
|
obj->flags |= FETCHING;
|
||||||
request = xmalloc(sizeof(*request));
|
CALLOC_ARRAY(request, 1);
|
||||||
request->obj = obj;
|
request->obj = obj;
|
||||||
request->url = NULL;
|
|
||||||
request->lock = NULL;
|
|
||||||
request->headers = NULL;
|
|
||||||
request->state = NEED_FETCH;
|
request->state = NEED_FETCH;
|
||||||
request->next = request_queue_head;
|
request->next = request_queue_head;
|
||||||
request_queue_head = request;
|
request_queue_head = request;
|
||||||
@@ -687,11 +685,9 @@ static int add_send_request(struct object *obj, struct remote_lock *lock)
|
|||||||
}
|
}
|
||||||
|
|
||||||
obj->flags |= PUSHING;
|
obj->flags |= PUSHING;
|
||||||
request = xmalloc(sizeof(*request));
|
CALLOC_ARRAY(request, 1);
|
||||||
request->obj = obj;
|
request->obj = obj;
|
||||||
request->url = NULL;
|
|
||||||
request->lock = lock;
|
request->lock = lock;
|
||||||
request->headers = NULL;
|
|
||||||
request->state = NEED_PUSH;
|
request->state = NEED_PUSH;
|
||||||
request->next = request_queue_head;
|
request->next = request_queue_head;
|
||||||
request_queue_head = request;
|
request_queue_head = request;
|
||||||
|
|||||||
Reference in New Issue
Block a user