From d406908e94d0c5baddc129830e482a980edebc43 Mon Sep 17 00:00:00 2001 From: hniksic Date: Sun, 17 Apr 2005 09:59:35 -0700 Subject: [PATCH] [svn] Fix potential memory leak in request_set_header. --- src/ChangeLog | 5 +++++ src/http.c | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index eccdebb2..c0dd819f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2005-04-17 Hrvoje Niksic + + * http.c (request_set_header): Free NAME when VALUE is NULL and + freeing the header name is requested. + 2005-04-17 Hrvoje Niksic * snprintf.c (fmtstr): Declare VALUE as const char *. diff --git a/src/http.c b/src/http.c index fd7ff440..c54eadf4 100644 --- a/src/http.c +++ b/src/http.c @@ -234,7 +234,13 @@ request_set_header (struct request *req, char *name, char *value, struct request_header *hdr; int i; if (!value) - return; + { + /* A NULL value is a no-op; if freeing the name is requested, + free it now to avoid leaks. */ + if (release_policy == rel_name || release_policy == rel_both) + xfree (name); + return; + } for (i = 0; i < req->hcount; i++) { hdr = &req->headers[i];