Skip to content

Commit

Permalink
Zero out stack frame ht
Browse files Browse the repository at this point in the history
  • Loading branch information
jbboehr committed Feb 13, 2024
1 parent 9a06bf2 commit 29ab657
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ static inline void vyrtue_context_stack_push(struct vyrtue_context_stack *stack,
zend_error_noreturn(E_COMPILE_ERROR, "vyrtue: stack overflow");
}

stack->data[stack->i].ast = ast;
stack->data[stack->i] = (struct vyrtue_context_stack_frame){
.ast = ast,
.ht = NULL,
};
stack->i++;
}

Expand All @@ -76,11 +79,14 @@ static inline void vyrtue_context_stack_pop(struct vyrtue_context_stack *stack,
zend_error_noreturn(E_COMPILE_ERROR, "vyrtue: stack pop mismatch");
}

stack->data[stack->i].ast = NULL;

if (stack->data[stack->i].ht) {
zend_hash_destroy(stack->data[stack->i].ht);
}

stack->data[stack->i] = (struct vyrtue_context_stack_frame){
.ast = NULL,
.ht = NULL,
};
}

VYRTUE_ATTR_NONNULL_ALL
Expand Down

0 comments on commit 29ab657

Please sign in to comment.