diff options
| author | Christian Marangi | 2023-05-26 17:25:35 +0000 |
|---|---|---|
| committer | Christian Marangi | 2023-05-26 17:25:35 +0000 |
| commit | 0e1c2fad3540fe3a17cbfa9cb3ac9d70670258f4 (patch) | |
| tree | 25d1025291684e820febb945bd48ec8f19eca18e | |
| parent | faaf9cee6ef4cd0f5e38713fa18824e9eef535e5 (diff) | |
| download | unetd-0e1c2fad3540fe3a17cbfa9cb3ac9d70670258f4.tar.gz | |
pex-msg: fix memory leak on fread fail in pex_msg_update_request_init
Fix Coverty Scan CID 1521052 memory leak on fread fail in
pex_msg_update_request_init.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
| -rw-r--r-- | pex-msg.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -424,8 +424,10 @@ pex_msg_update_request_init(const uint8_t *pubkey, const uint8_t *priv_key, memcpy(&ctx->addr, addr, sizeof(ctx->addr)); memcpy(ctx->auth_key, auth_key, sizeof(ctx->auth_key)); memcpy(ctx->priv_key, priv_key, sizeof(ctx->priv_key)); - if (!fread(&ctx->req_id, sizeof(ctx->req_id), 1, pex_urandom)) + if (!fread(&ctx->req_id, sizeof(ctx->req_id), 1, pex_urandom)) { + free(ctx); return NULL; + } list_add_tail(&ctx->list, &requests); if (!gc_timer.pending) uloop_timeout_set(&gc_timer, 1000); |