zig/stage1
Jonathan Marler 1165e13c25 wasm2c: avoid indexing null pointer triggering undefined behavior
Using zig cc to compile and run wasm2c on zig.wasm on Windows triggers
what appears to be a sanitizer crash.  The FuncGen reuse array pointer is
initialized to null and at some point it's resized to a length of zero,
which triggers this code to execute:

    memcpy(&self->reuse[self->reuse_i], &self->reuse[reuse_top], sizeof(uint32_t) * reuse_n);

Given the current values, this equates to:

    memcpy(&(NULL)[0], &(NULL)[0], 0);

Taking the address of the first element of a null pointer doesn't trigger
any actual runtime problem, since the pointer won't be dereferenced because
were passing 0 as the length to memcpy, however, it seems that the C spec
considers indexing a null pointer to be undefined behavior even if you
don't use the resulting value (or are just taking the address of an
indexed pointer).
2024-06-17 14:34:52 -04:00
..
config.h.in build.zig: add support for using "zig c++" as the bootstrap c++ compiler 2023-10-16 23:07:04 +02:00
config.zig.in compiler: audit debug mode checks 2024-03-01 17:42:54 -08:00
FuncGen.h wasm2c: avoid indexing null pointer triggering undefined behavior 2024-06-17 14:34:52 -04:00
InputStream.h
panic.h
wasi.c wasi.c: report no environment variables available 2024-02-27 22:55:00 -07:00
wasm2c.c wasm2c: fix allocation failure result 2024-03-23 11:32:37 +01:00
wasm.h
zig1.wasm update zig1.wasm 2024-05-08 19:37:29 -07:00
zig.h update zig1.wasm 2024-05-08 19:37:29 -07:00