[njs] Using correct code size addition.
Igor Sysoev
igor at sysoev.ru
Wed Apr 4 13:22:26 UTC 2018
details: http://hg.nginx.org/njs/rev/5fd1cb826b96
branches:
changeset: 492:5fd1cb826b96
user: Igor Sysoev <igor at sysoev.ru>
date: Wed Apr 04 16:21:09 2018 +0300
description:
Using correct code size addition.
Found by Clang Static Analyzer.
diffstat:
njs/njs_parser_expression.c | 22 ++++++++++------------
1 files changed, 10 insertions(+), 12 deletions(-)
diffs (53 lines):
diff -r c64c3f5b6328 -r 5fd1cb826b96 njs/njs_parser_expression.c
--- a/njs/njs_parser_expression.c Tue Apr 03 19:47:57 2018 +0300
+++ b/njs/njs_parser_expression.c Wed Apr 04 16:21:09 2018 +0300
@@ -862,6 +862,11 @@ njs_parser_inc_dec_expression(njs_vm_t *
return NJS_TOKEN_ILLEGAL;
}
+ parser->code_size += (parser->node->token == NJS_TOKEN_NAME)
+ ? sizeof(njs_vmcode_3addr_t)
+ : sizeof(njs_vmcode_3addr_t)
+ + sizeof(njs_vmcode_prop_set_t);
+
node = njs_parser_node_alloc(vm);
if (nxt_slow_path(node == NULL)) {
return NJS_TOKEN_ERROR;
@@ -873,12 +878,6 @@ njs_parser_inc_dec_expression(njs_vm_t *
node->left = parser->node;
parser->node = node;
- parser->code_size += (token == NJS_TOKEN_NAME)
- ? sizeof(njs_vmcode_3addr_t)
- : sizeof(njs_vmcode_prop_get_t)
- + sizeof(njs_vmcode_3addr_t)
- + sizeof(njs_vmcode_prop_set_t);
-
return next;
}
@@ -918,6 +917,11 @@ njs_parser_post_inc_dec_expression(njs_v
return NJS_TOKEN_ILLEGAL;
}
+ parser->code_size += (parser->node->token == NJS_TOKEN_NAME)
+ ? sizeof(njs_vmcode_3addr_t)
+ : sizeof(njs_vmcode_3addr_t)
+ + sizeof(njs_vmcode_prop_set_t);
+
node = njs_parser_node_alloc(vm);
if (nxt_slow_path(node == NULL)) {
return NJS_TOKEN_ERROR;
@@ -929,12 +933,6 @@ njs_parser_post_inc_dec_expression(njs_v
node->left = parser->node;
parser->node = node;
- parser->code_size += (token == NJS_TOKEN_NAME)
- ? sizeof(njs_vmcode_3addr_t)
- : sizeof(njs_vmcode_prop_get_t)
- + sizeof(njs_vmcode_3addr_t)
- + sizeof(njs_vmcode_prop_set_t);
-
return njs_parser_token(parser);
}
More information about the nginx-devel
mailing list