[njs] Fixed use-of-uninitialized-value after 1d0825906438.
Dmitry Volyntsev
xeioex at nginx.com
Wed May 27 13:39:51 UTC 2020
details: https://hg.nginx.org/njs/rev/4fb07fcbb698
branches:
changeset: 1404:4fb07fcbb698
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Wed May 27 12:02:59 2020 +0000
description:
Fixed use-of-uninitialized-value after 1d0825906438.
Found by Coverity (CID 1463834).
diffstat:
src/njs_array.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diffs (34 lines):
diff -r 1b8a0af35e2b -r 4fb07fcbb698 src/njs_array.c
--- a/src/njs_array.c Tue May 26 19:03:11 2020 +0000
+++ b/src/njs_array.c Wed May 27 12:02:59 2020 +0000
@@ -3254,7 +3254,10 @@ njs_array_prototype_sort(njs_vm_t *vm, n
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, n
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, n
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;
More information about the nginx-devel
mailing list