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

Dmitry Volyntsev xeioex at nginx.com
Thu Aug 27 14:43:52 UTC 2020


details:   https://hg.nginx.org/njs/rev/da7d4c125a9c
branches:  
changeset: 1507:da7d4c125a9c
user:      Dmitry Volyntsev <xeioex at 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",


More information about the nginx-devel mailing list