Skip to content

Commit 0941741

Browse files
committed
fix crash get_upstreams when no stream/htt module configured
1 parent ccacc4c commit 0941741

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/ngx_dynamic_upstream_lua.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ ngx_http_dynamic_upstream_lua_get_upstreams(lua_State *L)
291291
}
292292

293293
umcf = ngx_http_lua_upstream_get_upstream_main_conf(L);
294+
if (umcf == NULL) {
295+
lua_pushboolean(L, 1);
296+
lua_newtable(L);
297+
return 2;
298+
}
299+
294300
uscfp = umcf->upstreams.elts;
295301

296302
lua_pushboolean(L, 1);

src/ngx_dynamic_upstream_stream_lua.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ ngx_stream_dynamic_upstream_lua_get_upstreams(lua_State *L)
275275
}
276276

277277
umcf = ngx_stream_lua_upstream_get_upstream_main_conf();
278+
if (umcf == NULL) {
279+
lua_pushboolean(L, 1);
280+
lua_newtable(L);
281+
return 2;
282+
}
283+
278284
uscfp = umcf->upstreams.elts;
279285

280286
lua_pushboolean(L, 1);

0 commit comments

Comments
 (0)