From: Dmitry Volyntsev Date: Wed, 27 May 2020 12:02:59 +0000 (+0000) Subject: Fixed use-of-uninitialized-value after 1d0825906438. X-Git-Tag: 0.4.2~54 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/static/gitweb.js?a=commitdiff_plain;h=88caecba84b1bcf2512c07a6bcb21c1432bd1541;p=njs.git Fixed use-of-uninitialized-value after 1d0825906438. Found by Coverity (CID 1463834). --- diff --git a/src/njs_array.c b/src/njs_array.c index ce449666..486062d7 100644 --- a/src/njs_array.c +++ b/src/njs_array.c @@ -3254,7 +3254,10 @@ njs_array_prototype_sort(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, return NJS_OK; } + slots = NULL; ctx.vm = vm; + ctx.strings.separate = 0; + ctx.strings.pointer = 0; ctx.exception = 0; if (njs_fast_path(njs_is_fast_array(this))) { @@ -3304,7 +3307,6 @@ njs_array_prototype_sort(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, und = 0; p = NULL; end = NULL; - slots = NULL; for (i = 0; i < length; i++) { if (p >= end) { @@ -3406,7 +3408,10 @@ njs_array_prototype_sort(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, exception: - njs_mp_free(vm->mem_pool, slots); + if (slots != NULL) { + njs_mp_free(vm->mem_pool, slots); + } + njs_arr_destroy(&ctx.strings); return ret;