diff --git a/CMakeLists.txt b/CMakeLists.txt index aabaf5a69..5af3fef6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,6 @@ xcheck_add_c_compiler_flag(-Wno-unused-parameter) xcheck_add_c_compiler_flag(-Wno-unused-but-set-variable) xcheck_add_c_compiler_flag(-Wno-array-bounds) xcheck_add_c_compiler_flag(-Wno-format-truncation) -xcheck_add_c_compiler_flag(-Wno-format-zero-length) xcheck_add_c_compiler_flag(-funsigned-char) # ClangCL is command line compatible with MSVC, so 'MSVC' is set. diff --git a/cutils.h b/cutils.h index 76cb460bd..7830d0aeb 100644 --- a/cutils.h +++ b/cutils.h @@ -49,7 +49,7 @@ extern "C" { #elif defined(_WIN32) #include #endif -#if !defined(_WIN32) +#if !defined(_WIN32) && !defined(EMSCRIPTEN) && !defined(__wasi__) #include #include #endif diff --git a/libbf.c b/libbf.c index 5d48db622..6293f4ea1 100644 --- a/libbf.c +++ b/libbf.c @@ -1710,6 +1710,13 @@ static int __bf_div(bf_t *r, const bf_t *a, const bf_t *b, limb_t prec, slimb_t d; na = n + nb; + +#if LIMB_LOG2_BITS == 6 + if (na >= (SIZE_MAX / sizeof(limb_t)) - 1) { + return BF_ST_MEM_ERROR; /* Return memory error status */ + } +#endif + taba = bf_malloc(s, (na + 1) * sizeof(limb_t)); if (!taba) goto fail; diff --git a/quickjs.c b/quickjs.c index bdc0cc885..a8a742477 100644 --- a/quickjs.c +++ b/quickjs.c @@ -62,7 +62,7 @@ #define NO_TM_GMTOFF #endif -#if !defined(EMSCRIPTEN) && !defined(__wasi__) +#if !defined(EMSCRIPTEN) && !defined(__wasi__) && !defined(__STDC_NO_ATOMICS__) #include "quickjs-c-atomics.h" #define CONFIG_ATOMICS #endif @@ -6673,7 +6673,7 @@ static void build_backtrace(JSContext *ctx, JSValue error_obj, } done: if (has_prepare) { - int j = 0; + int j = 0, k; stack = JS_NewArray(ctx); if (JS_IsException(stack)) { stack = JS_NULL; @@ -6689,7 +6689,7 @@ static void build_backtrace(JSContext *ctx, JSValue error_obj, } } // Clear the csd's we didn't use in case of error. - for (int k = j; k < i; k++) { + for (k = j; k < i; k++) { JS_FreeValue(ctx, csd[k].filename); JS_FreeValue(ctx, csd[k].func); JS_FreeValue(ctx, csd[k].func_name); @@ -34643,7 +34643,7 @@ static JSString *JS_ReadString(BCReaderState *s) } #ifdef DUMP_READ_OBJECT if (check_dump_flag(s->ctx->rt, DUMP_READ_OBJECT)) { - bc_read_trace(s, ""); // hex dump and indentation + bc_read_trace(s, "%s", ""); // hex dump and indentation JS_DumpString(s->ctx->rt, p); printf("\n"); } @@ -34703,7 +34703,7 @@ static int JS_ReadFunctionBytecode(BCReaderState *s, JSFunctionBytecode *b, const uint8_t *save_ptr = s->ptr; s->ptr = s->ptr_last + len; s->level -= 4; - bc_read_trace(s, ""); // hex dump + indent + bc_read_trace(s, "%s", ""); // hex dump + indent dump_single_byte_code(s->ctx, bc_buf + pos, b, s->ptr - s->buf_start - len); s->level += 4; @@ -49847,7 +49847,9 @@ static struct { }; static BOOL string_get_tzabbr(const uint8_t *sp, int *pp, int *offset) { - for (size_t i = 0; i < countof(js_tzabbr); i++) { + size_t i; + + for (i = 0; i < countof(js_tzabbr); i++) { if (string_match(sp, pp, js_tzabbr[i].name)) { *offset = js_tzabbr[i].offset; return TRUE;