Opened 2 years ago

Closed 2 years ago

#1531 closed defect (invalid)

ngx_rbtree.h

Reported by: lwppwl@… Owned by:
Priority: minor Milestone:
Component: other Version: 1.13.x
Keywords: Cc:
uname -a: Linux lwp-All-Series 4.10.0-19-generic #21-Ubuntu SMP Thu Apr 6 17:04:57 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx-1.12.2

Description

in ngx_rbtree.h

in function ngx_rbtree_min()

static ngx_inline ngx_rbtree_node_t *
ngx_rbtree_min(ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel)
{

while (node->left != sentinel)
{

node = node->left;

}


return node;

}

after delete all node, when call ngx_rbtree_min(tree->root, tree->sentinel) casue Segment error.

should be fix like this:

static inline ngx_rbtree_node_t *
ngx_rbtree_min(ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel)
{

while (node != sentinel && node->left != sentinel)
{

node = node->left;

}


if (node == sentinel)
{

return NULL;

}


return node;

}

Change History (1)

comment:1 by Maxim Dounin, 2 years ago

Resolution: invalid
Status: newclosed

You shouldn't call ngx_rbtree_min() on an empty tree. See ngx_event_find_timer() or ngx_event_expire_timers() in src/event/ngx_event_timer.c for usage examples.

Note: See TracTickets for help on using tickets.