mirror of
https://github.com/danog/ir.git
synced 2025-01-22 05:31:32 +01:00
Fix memory leak
This commit is contained in:
parent
844653cfd1
commit
1df594fea5
@ -5259,11 +5259,16 @@ const void *ir_emit_exitgroup(uint32_t first_exit_point, uint32_t exit_points_pe
|
||||
ret = dasm_link(&dasm_state, &size);
|
||||
if (ret != DASM_S_OK) {
|
||||
IR_ASSERT(0);
|
||||
dasm_free(&data.dasm_state);
|
||||
if (code_buffer == NULL) {
|
||||
ir_mem_unmap(entry, size);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (code_buffer != NULL) {
|
||||
if (IR_ALIGNED_SIZE(size, 16) > code_buffer_size) {
|
||||
dasm_free(&data.dasm_state);
|
||||
return NULL;
|
||||
}
|
||||
entry = code_buffer;
|
||||
@ -5276,6 +5281,7 @@ const void *ir_emit_exitgroup(uint32_t first_exit_point, uint32_t exit_points_pe
|
||||
ret = dasm_encode(&dasm_state, entry);
|
||||
if (ret != DASM_S_OK) {
|
||||
IR_ASSERT(0);
|
||||
dasm_free(&data.dasm_state);
|
||||
if (code_buffer == NULL) {
|
||||
ir_mem_unmap(entry, size);
|
||||
}
|
||||
|
@ -8042,12 +8042,17 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr)
|
||||
ret = dasm_link(&data.dasm_state, size_ptr);
|
||||
if (ret != DASM_S_OK) {
|
||||
IR_ASSERT(0);
|
||||
dasm_free(&data.dasm_state);
|
||||
if (ctx->code_buffer == NULL) {
|
||||
ir_mem_unmap(entry, size);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
size = *size_ptr;
|
||||
|
||||
if (ctx->code_buffer != NULL) {
|
||||
if (IR_ALIGNED_SIZE(size, 16) > ctx->code_buffer_size) {
|
||||
dasm_free(&data.dasm_state);
|
||||
return NULL;
|
||||
}
|
||||
entry = ctx->code_buffer;
|
||||
@ -8060,6 +8065,7 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr)
|
||||
ret = dasm_encode(&data.dasm_state, entry);
|
||||
if (ret != DASM_S_OK) {
|
||||
IR_ASSERT(0);
|
||||
dasm_free(&data.dasm_state);
|
||||
if (ctx->code_buffer == NULL) {
|
||||
ir_mem_unmap(entry, size);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user