Welcome! Log In Create A New Profile

Advanced

[njs] Parser: fixed njs_queue_remove() macro usage.

Dmitry Volyntsev
August 27, 2020 10:46AM
details: https://hg.nginx.org/njs/rev/da7d4c125a9c
branches:
changeset: 1507:da7d4c125a9c
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Thu Aug 27 14:43:19 2020 +0000
description:
Parser: fixed njs_queue_remove() macro usage.

The issue caused segfault when NJS_DEBUG is defined.

The issue was introduced in 86f55a7dc4a4.

diffstat:

src/njs_parser.c | 4 +++-
src/njs_parser.h | 5 +++--
2 files changed, 6 insertions(+), 3 deletions(-)

diffs (40 lines):

diff -r fbee1514cf43 -r da7d4c125a9c src/njs_parser.c
--- a/src/njs_parser.c Wed Aug 26 21:11:03 2020 +0300
+++ b/src/njs_parser.c Thu Aug 27 14:43:19 2020 +0000
@@ -480,13 +480,15 @@ njs_parser_not_supported(njs_parser_t *p
njs_inline njs_int_t
njs_parser_reject(njs_parser_t *parser)
{
+ njs_queue_link_t *link;
njs_parser_stack_entry_t *entry;

while (!njs_queue_is_empty(&parser->stack)) {
entry = njs_queue_link_data(njs_queue_first(&parser->stack),
njs_parser_stack_entry_t, link);

- njs_queue_remove(njs_queue_first(&parser->stack));
+ link = njs_queue_first(&parser->stack);
+ njs_queue_remove(link);

if (!entry->optional) {
njs_parser_next(parser, entry->state);
diff -r fbee1514cf43 -r da7d4c125a9c src/njs_parser.h
--- a/src/njs_parser.h Wed Aug 26 21:11:03 2020 +0300
+++ b/src/njs_parser.h Thu Aug 27 14:43:19 2020 +0000
@@ -280,13 +280,14 @@ njs_parser_height(njs_parser_t *parser,
njs_inline njs_int_t
njs_parser_stack_pop(njs_parser_t *parser)
{
+ njs_queue_link_t *link;
njs_parser_stack_entry_t *entry;

-
entry = njs_queue_link_data(njs_queue_first(&parser->stack),
njs_parser_stack_entry_t, link);

- njs_queue_remove(njs_queue_first(&parser->stack));
+ link = njs_queue_first(&parser->stack);
+ njs_queue_remove(link);

#ifdef NJS_PARSER_DEBUG
njs_printf(" stack_pop(%d)\n",
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Parser: fixed njs_queue_remove() macro usage.

Dmitry Volyntsev 93 August 27, 2020 10:46AM



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

Online Users

Guests: 67
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