From 3aaebe4169f80707e495f1111b7ab9c2dcb79b6d Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Thu, 30 May 2019 15:33:51 +0300 Subject: Fixed segfault with empty routes array. --- src/nxt_http_route.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/nxt_http_route.c') diff --git a/src/nxt_http_route.c b/src/nxt_http_route.c index 2a41d7fa..21e83ecb 100644 --- a/src/nxt_http_route.c +++ b/src/nxt_http_route.c @@ -616,14 +616,13 @@ nxt_http_route_find(nxt_http_routes_t *routes, nxt_str_t *name) route = &routes->route[0]; end = route + routes->items; - do { + while (route < end) { if (nxt_strstr_eq(&(*route)->name, name)) { return *route; } route++; - - } while (route < end); + } return NULL; } @@ -681,12 +680,11 @@ nxt_http_routes_cleanup(nxt_task_t *task, nxt_http_routes_t *routes) route = &routes->route[0]; end = route + routes->items; - do { + while (route < end) { nxt_http_route_cleanup(task, *route); route++; - - } while (route < end); + } } } @@ -699,12 +697,11 @@ nxt_http_route_cleanup(nxt_task_t *task, nxt_http_route_t *route) match = &route->match[0]; end = match + route->items; - do { + while (match < end) { nxt_http_pass_cleanup(task, &(*match)->pass); match++; - - } while (match < end); + } } -- cgit