Skip to content
Myr

Remove undefined behavior caught by LLVM 10 UBSAN.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Gaelan Steele · committed by Nico Williams · parent 6b6feaf · Browse files · 1 file+5 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−3 removed

  • other:+5 added−3 removed

1 file+5 added−3 removed

modified:src/exec_stack.h+5 added-3 removed
59 unmodified lines
60}6162static void stack_reset(struct stack* s) {63 assert(s->limit == 0 && "stack freed while not empty");64 if(s->mem_end != NULL) {64 char* mem_start = s->mem_end - ( -s->bound + ALIGNMENT);65 free(mem_start);65 char* mem_start = s->mem_end - ( -s->bound + ALIGNMENT);66 free(mem_start);67 }68 stack_init(s);69}7071static int stack_pop_will_free(struct stack* s, stack_ptr p) {
9 unmodified lines
81}8283static void stack_reallocate(struct stack* s, size_t sz) {84 int old_mem_length = -(s->bound) + ALIGNMENT;83 char* old_mem_start = s->mem_end - old_mem_length;85 char* old_mem_start = (s->mem_end != NULL) ? (s->mem_end - old_mem_length) : NULL;8687 int new_mem_length = align_round_up((old_mem_length + sz + 256) * 2);88 char* new_mem_start = jv_mem_realloc(old_mem_start, new_mem_length);89 memmove(new_mem_start + (new_mem_length - old_mem_length),
25 unmodified lines