commit c011abc4ddacb12ebca1e091d241a782f0e8a2f2 (tree) parent a7282d09101b4339fc71d5ea78927c598aee0f52 Author: Jacob Young <jacobly0@users.noreply.github.com> Date: Sat, 23 Mar 2024 02:50:36 +0100 wasm2c: fix allocation failure result Diffstat:
| M | stage1/wasm2c.c | | | 6 | +++--- |
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/stage1/wasm2c.c b/stage1/wasm2c.c @@ -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"