*
* Caller must free the result
*/
-static struct http_hdr *hlua_httpclient_table_to_hdrs(lua_State *L)
+__LJMP static struct http_hdr *hlua_httpclient_table_to_hdrs(lua_State *L)
{
struct http_hdr hdrs[global.tune.max_http_hdr];
struct http_hdr *result = NULL;
}
if (hdr_num >= global.tune.max_http_hdr) {
- lua_pop(L, 2);
- goto skip_headers;
+ while (hdr_num--) {
+ istfree(&hdrs[hdr_num].n);
+ istfree(&hdrs[hdr_num].v);
+ }
+ WILL_LJMP(luaL_error(L, "too many headers (tune.http.maxhdr is %d)",
+ global.tune.max_http_hdr));
}
v = lua_tolstring(L, -1, &vlen);
} else if (strcmp(lua_tostring(L, -2), "headers") == 0) {
if (lua_type(L, -1) != LUA_TTABLE)
WILL_LJMP(luaL_error(L, "invalid parameter in 'headers', must be a table"));
- hdrs = hlua_httpclient_table_to_hdrs(L);
+ hdrs = MAY_LJMP(hlua_httpclient_table_to_hdrs(L));
} else if (strcmp(lua_tostring(L, -2), "body") == 0) {
if (lua_type(L, -1) != LUA_TSTRING)