diff --git a/src/duk_alloc_default.c b/src/duk_alloc_default.c index 48dc43c1..6442aa7d 100644 --- a/src/duk_alloc_default.c +++ b/src/duk_alloc_default.c @@ -9,6 +9,7 @@ void *duk_default_alloc_function(void *udata, size_t size) { void *res; + DUK_UNREF(udata); res = malloc(size); DUK_DDDPRINT("default alloc function: %d -> %p", size, res); return res; @@ -16,6 +17,7 @@ void *duk_default_alloc_function(void *udata, size_t size) { void *duk_default_realloc_function(void *udata, void *ptr, size_t newsize) { void *res; + DUK_UNREF(udata); res = realloc(ptr, newsize); DUK_DDDPRINT("default realloc function: %p %d -> %p", ptr, newsize, res); return res; @@ -23,6 +25,7 @@ void *duk_default_realloc_function(void *udata, void *ptr, size_t newsize) { void duk_default_free_function(void *udata, void *ptr) { DUK_DDDPRINT("default free function: %p", ptr); + DUK_UNREF(udata); free(ptr); } diff --git a/src/duk_alloc_torture.c b/src/duk_alloc_torture.c index c4c03384..68c8cf4f 100644 --- a/src/duk_alloc_torture.c +++ b/src/duk_alloc_torture.c @@ -16,16 +16,19 @@ void *duk_torture_alloc_function(void *udata, size_t size) { DUK_DDDPRINT("torture alloc function: %d", size); + DUK_UNREF(udata); return malloc(size); } void *duk_torture_realloc_function(void *udata, void *ptr, size_t newsize) { DUK_DDDPRINT("torture realloc function: %p %d", ptr, newsize); + DUK_UNREF(udata); return realloc(ptr, newsize); } void duk_torture_free_function(void *udata, void *ptr) { DUK_DDDPRINT("torture free function: %p", ptr); + DUK_UNREF(udata); free(ptr); } diff --git a/src/duk_builtin_error.c b/src/duk_builtin_error.c index 4563f085..85967d44 100644 --- a/src/duk_builtin_error.c +++ b/src/duk_builtin_error.c @@ -324,5 +324,6 @@ int duk_builtin_error_prototype_nop_setter(duk_context *ctx) { * User can use Object.defineProperty() to override this behavior. */ DUK_ASSERT_TOP(ctx, 1); /* fixed arg count */ + DUK_UNREF(ctx); return 0; } diff --git a/src/duk_builtin_function.c b/src/duk_builtin_function.c index cc14ec62..3a720c8f 100644 --- a/src/duk_builtin_function.c +++ b/src/duk_builtin_function.c @@ -74,6 +74,7 @@ int duk_builtin_function_constructor(duk_context *ctx) { int duk_builtin_function_prototype(duk_context *ctx) { /* ignore arguments, return undefined (E5 Section 15.3.4) */ + DUK_UNREF(ctx); return 0; } diff --git a/src/duk_builtin_global.c b/src/duk_builtin_global.c index 2ef6e66b..014feb78 100644 --- a/src/duk_builtin_global.c +++ b/src/duk_builtin_global.c @@ -197,9 +197,10 @@ static void duk_transform_callback_encode_uri(duk_transform_context *tfm_ctx, vo static void duk_transform_callback_decode_uri(duk_transform_context *tfm_ctx, void *udata, duk_codepoint_t cp) { duk_uint8_t *reserved_table = (duk_uint8_t *) udata; - duk_small_int_t utf8_blen; + duk_small_uint_t utf8_blen; duk_codepoint_t min_cp; - duk_small_int_t t, i; + duk_small_int_t t; /* must be signed */ + duk_small_uint_t i; if (cp == (duk_codepoint_t) '%') { duk_uint8_t *p = tfm_ctx->p; @@ -323,6 +324,8 @@ static void duk_transform_callback_escape(duk_transform_context *tfm_ctx, void * duk_uint8_t buf[6]; duk_small_int_t len; + DUK_UNREF(udata); + if (cp < 0) { goto esc_error; } else if ((cp < 0x80L) && CHECK_BITMASK(escape_unescaped_table, cp)) { @@ -360,6 +363,8 @@ static void duk_transform_callback_escape(duk_transform_context *tfm_ctx, void * static void duk_transform_callback_unescape(duk_transform_context *tfm_ctx, void *udata, duk_codepoint_t cp) { duk_small_int_t t; + DUK_UNREF(udata); + if (cp == (duk_codepoint_t) '%') { duk_uint8_t *p = tfm_ctx->p; duk_size_t left = (duk_size_t) (tfm_ctx->p_end - p); /* bytes left */ diff --git a/src/duk_js_var.c b/src/duk_js_var.c index b9b8b6be..4aad7b73 100644 --- a/src/duk_js_var.c +++ b/src/duk_js_var.c @@ -83,6 +83,7 @@ static void increase_data_inner_refcounts(duk_hthread *thr, duk_hcompiledfunctio duk_hobject **funcs, **funcs_end; DUK_ASSERT(f->data != NULL); /* compiled functions must be created 'atomically' */ + DUK_UNREF(thr); tv = DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE(f); tv_end = DUK_HCOMPILEDFUNCTION_GET_CONSTS_END(f); @@ -123,7 +124,7 @@ void duk_js_push_closure(duk_hthread *thr, duk_hobject *outer_lex_env) { duk_context *ctx = (duk_context *) thr; duk_hcompiledfunction *fun_clos; - int i; + duk_small_uint_t i; duk_uint32_t len_value; DUK_ASSERT(fun_temp != NULL); @@ -306,7 +307,7 @@ void duk_js_push_closure(duk_hthread *thr, DUK_DDDPRINT("copying properties: closure=%!iT, template=%!iT", duk_get_tval(ctx, -2), duk_get_tval(ctx, -1)); - for (i = 0; i < sizeof(duk_closure_copy_proplist) / sizeof(duk_uint16_t); i++) { + for (i = 0; i < (duk_small_uint_t) (sizeof(duk_closure_copy_proplist) / sizeof(duk_uint16_t)); i++) { int stridx = (int) duk_closure_copy_proplist[i]; if (duk_get_prop_stridx(ctx, -1, stridx)) { /* [ ... closure template val ] */ @@ -543,7 +544,7 @@ void duk_js_init_activation_environment_records_delayed(duk_hthread *thr, void duk_js_close_environment_record(duk_hthread *thr, duk_hobject *env, duk_hobject *func, int regbase) { duk_context *ctx = (duk_context *) thr; - int i; + duk_uint_fast32_t i; DUK_ASSERT(thr != NULL); DUK_ASSERT(env != NULL); @@ -630,7 +631,7 @@ void duk_js_close_environment_record(duk_hthread *thr, duk_hobject *env, duk_hob DUK_DDDPRINT("copying bound register values, %d bound regs", varmap->e_used); - for (i = 0; i < varmap->e_used; i++) { + for (i = 0; i < (duk_uint_fast32_t) varmap->e_used; i++) { key = DUK_HOBJECT_E_GET_KEY(varmap, i); DUK_ASSERT(key != NULL); /* assume keys are compacted */ diff --git a/src/duk_lexer.c b/src/duk_lexer.c index 2ff53c03..ef38e8fe 100644 --- a/src/duk_lexer.c +++ b/src/duk_lexer.c @@ -1625,7 +1625,11 @@ static void emit_u16_direct_ranges(duk_lexer_ctx *lex_ctx, void *userdata, duk_uint16_t *ranges, int num) { - duk_uint16_t *ranges_end = ranges + num; + duk_uint16_t *ranges_end; + + DUK_UNREF(lex_ctx); + + ranges_end = ranges + num; while (ranges < ranges_end) { /* mark range 'direct', bypass canonicalization (see Wiki) */ gen_range(userdata, (duk_codepoint_t) ranges[0], (duk_codepoint_t) ranges[1], 1); diff --git a/src/duk_unicode_support.c b/src/duk_unicode_support.c index 0dde1fd9..62898730 100644 --- a/src/duk_unicode_support.c +++ b/src/duk_unicode_support.c @@ -143,6 +143,8 @@ duk_small_int_t duk_unicode_decode_xutf8(duk_hthread *thr, duk_uint8_t **ptr, du duk_uint_fast8_t ch; duk_small_int_t n; + DUK_UNREF(thr); + p = *ptr; if (p < ptr_start || p >= ptr_end) { goto fail; @@ -713,6 +715,8 @@ static duk_codepoint_t case_transform_helper(duk_hthread *thr, duk_small_int_t language) { duk_bitdecoder_ctx bd_ctx; + DUK_UNREF(language); + /* fast path for ASCII */ if (cp < 0x80L) { /* FIXME: context sensitive rules exist for ASCII range too.