Fix use-after-free in error path
parent
a9d9547930
commit
41f30bf7ca
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue