From: Igor Sysoev Date: Tue, 11 Oct 2016 14:04:28 +0000 (+0300) Subject: Segfaults in increment and decrement operators have been fixed. X-Git-Tag: 0.1.4~20 X-Git-Url: http://git.kaiwu.me/sitemap.xml?a=commitdiff_plain;h=b74583ee6da1d3e0a87fe75f2bd0f3d73ae02439;p=njs.git Segfaults in increment and decrement operators have been fixed. --- 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") },