Skip to content

Commit

Permalink
* src/ne_redirect.c (post_send): Rejig logic to fix a memory leak for
Browse files Browse the repository at this point in the history
  a 2xx response with a Location header introduced in commit 2931acd.
  • Loading branch information
notroj committed Sep 4, 2024
1 parent 8de3842 commit 6fabaf3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/ne_redirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,17 @@ static void create(ne_request *req, void *userdata,
static int post_send(ne_request *req, void *userdata, const ne_status *status)
{
struct redirect *red = userdata;
ne_uri *loc = ne_get_response_location(req, NULL);
ne_uri *loc;

uri_free_clear(red);

if (status->klass != 3 || loc == NULL) {
return NE_OK;
if (status->klass == 3
&& (loc = ne_get_response_location(req, NULL)) != NULL) {
red->uri = loc;
return NE_REDIRECT;
}

red->uri = loc;
return NE_REDIRECT;
return NE_OK;
}

static void free_redirect(void *cookie)
Expand Down

0 comments on commit 6fabaf3

Please sign in to comment.