Skip to content

Commit

Permalink
janssonrpc-c: Fix double free if retry timer add fails
Browse files Browse the repository at this point in the history
- Fix double free if schedule_retry fails when adding
  request retry timer. timeout_cb called fail_request
  which frees req after schedule_retry had already
  done so.

(cherry picked from commit bce9cf9)
  • Loading branch information
doublec authored and miconda committed Oct 1, 2015
1 parent 3b2946b commit 8ffab1c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/janssonrpc-c/janssonrpc_request.c
Expand Up @@ -253,8 +253,6 @@ int schedule_retry(jsonrpc_request_t* req)

new_req->ntries = req->ntries;

free_request(req);

const struct timeval tv = ms_to_tv(time);

new_req->retry_ev = evtimer_new(global_ev_base, retry_cb, (void*)new_req);
Expand All @@ -264,6 +262,8 @@ int schedule_retry(jsonrpc_request_t* req)
goto error;
}

free_request(req);

return 0;
error:
ERR("schedule_retry failed.\n");
Expand Down

0 comments on commit 8ffab1c

Please sign in to comment.