Welcome! Log In Create A New Profile

Advanced

[njs] Using correct code size addition.

April 04, 2018 09:24AM
details: http://hg.nginx.org/njs/rev/5fd1cb826b96
branches:
changeset: 492:5fd1cb826b96
user: Igor Sysoev <igor@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);
}

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Using correct code size addition.

Igor Sysoev 682 April 04, 2018 09:24AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 86
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready