From b74583ee6da1d3e0a87fe75f2bd0f3d73ae02439 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Tue, 11 Oct 2016 17:04:28 +0300 Subject: [PATCH] Segfaults in increment and decrement operators have been fixed. --- njs/njs_generator.c | 4 +++- njs/test/njs_unit_test.c | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/njs/njs_generator.c b/njs/njs_generator.c index 72bc6e98..a262638e 100644 --- a/njs/njs_generator.c +++ b/njs/njs_generator.c @@ -21,6 +21,7 @@ #include #include #include +#include static nxt_int_t njs_generator(njs_vm_t *vm, njs_parser_t *parser, @@ -1848,7 +1849,8 @@ njs_generate_inc_dec_operation(njs_vm_t *vm, njs_parser_t *parser, if (node->dest != NULL) { dest_index = node->dest->index; - if (dest_index != lvalue->left->index + if (dest_index != NJS_INDEX_NONE + && dest_index != lvalue->left->index && dest_index != lvalue->right->index) { node->index = dest_index; diff --git a/njs/test/njs_unit_test.c b/njs/test/njs_unit_test.c index c0e700fc..f1e9fa86 100644 --- a/njs/test/njs_unit_test.c +++ b/njs/test/njs_unit_test.c @@ -471,6 +471,9 @@ static njs_unit_test_t njs_test[] = { nxt_string("[[]+[]]-[]+[[]-[]]"), nxt_string("00") }, + { nxt_string("!--[][1]"), + nxt_string("true") }, + { nxt_string("'true' == true"), nxt_string("false") }, -- 2.47.3