Fix use-after-free in error path

pull/73/head
Antonin Décimo 2020-10-01 01:01:12 +02:00 committed by Andri Yngvason
parent a9d9547930
commit 41f30bf7ca
1 changed files with 2 additions and 2 deletions

View File

@ -100,8 +100,8 @@ static void receive_data(void* data,
ctx->offer = offer; ctx->offer = offer;
ctx->mem_fp = open_memstream(&ctx->mem_data, &ctx->mem_size); ctx->mem_fp = open_memstream(&ctx->mem_data, &ctx->mem_size);
if (!ctx->mem_fp) { if (!ctx->mem_fp) {
free(ctx);
close(ctx->fd); close(ctx->fd);
free(ctx);
log_error("open_memstream() failed: %m\n"); log_error("open_memstream() failed: %m\n");
return; return;
} }
@ -109,8 +109,8 @@ static void receive_data(void* data,
struct aml_handler* handler = aml_handler_new(ctx->fd, on_receive, struct aml_handler* handler = aml_handler_new(ctx->fd, on_receive,
ctx, destroy_receive_context); ctx, destroy_receive_context);
if (!handler) { if (!handler) {
free(ctx);
close(ctx->fd); close(ctx->fd);
free(ctx);
return; return;
} }