mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 00:52:52 +00:00
wasm2c: fix allocation failure result
This commit is contained in:
parent
a7282d0910
commit
c011abc4dd
@ -261,13 +261,13 @@ int main(int argc, char **argv) {
|
||||
" uint8_t *new_m = *m;\n"
|
||||
" uint32_t r = *p;\n"
|
||||
" uint32_t new_p = r + n;\n"
|
||||
" if (new_p > UINT32_C(0x10000)) return UINT32_C(0xFFFFFFF);\n"
|
||||
" if (new_p > UINT32_C(0xFFFF)) return UINT32_C(0xFFFFFFFF);\n"
|
||||
" uint32_t new_c = *c;\n"
|
||||
" if (new_c < new_p) {\n"
|
||||
" do new_c += new_c / 2 + 8; while (new_c < new_p);\n"
|
||||
" if (new_c > UINT32_C(0x10000)) new_c = UINT32_C(0x10000);\n"
|
||||
" if (new_c > UINT32_C(0xFFFF)) new_c = UINT32_C(0xFFFF);\n"
|
||||
" new_m = realloc(new_m, new_c << 16);\n"
|
||||
" if (new_m == NULL) return UINT32_C(0xFFFFFFF);\n"
|
||||
" if (new_m == NULL) return UINT32_C(0xFFFFFFFF);\n"
|
||||
" *m = new_m;\n"
|
||||
" *c = new_c;\n"
|
||||
" }\n"
|
||||
|
Loading…
Reference in New Issue
Block a user