Skip to content

Commit

Permalink
Fix leak in heap
Browse files Browse the repository at this point in the history
  • Loading branch information
infradig committed Apr 22, 2023
1 parent b91b8fe commit 099e4d5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,15 +449,15 @@ cell *deep_copy_to_heap(query *q, cell *p1, pl_idx_t p1_ctx, bool copy_attrs)

cell *deep_copy_to_heap_with_replacement(query *q, cell *p1, pl_idx_t p1_ctx, bool copy_attrs, cell *from, pl_idx_t from_ctx, cell *to, pl_idx_t to_ctx)
{
void *save = q->vars;
if (q->vars) map_destroy(q->vars);
q->vars = map_create(NULL, NULL, NULL);
if (!q->vars) return NULL;
const frame *f = GET_CURR_FRAME();
q->varno = f->actual_slots;
q->tab_idx = 0;
cell *tmp = deep_copy_to_tmp_with_replacement(q, p1, p1_ctx, copy_attrs, from, from_ctx, to, to_ctx);
map_destroy(q->vars);
q->vars = save;
q->vars = NULL;
if (!tmp) return NULL;
cell *tmp2 = alloc_on_heap(q, tmp->nbr_cells);
if (!tmp2) return NULL;
Expand Down

0 comments on commit 099e4d5

Please sign in to comment.