Permalink
Browse files

bugfix: there were various places where we did not check the pointer …

…returned by the memory allocator.
  • Loading branch information...
1 parent b35bcb2 commit 29e8b41e99d433a5327039de7025c6c7c398ce6f @agentzh agentzh committed Dec 16, 2011
Showing with 17 additions and 1 deletion.
  1. +4 −0 src/ngx_http_lua_args.c
  2. +8 −0 src/ngx_http_lua_control.c
  3. +4 −0 src/ngx_http_lua_uri.c
  4. +1 −1 src/ngx_http_lua_util.c
View
@@ -41,6 +41,10 @@ ngx_http_lua_ngx_req_set_uri_args(lua_State *L) {
p = (u_char *) lua_tolstring(L, 1, &len);
args.data = ngx_palloc(r->pool, len);
+ if (args.data == NULL) {
+ return luaL_error(L, "out of memory");
+ }
+
ngx_memcpy(args.data, p, len);
args.len = len;
@@ -69,6 +69,10 @@ ngx_http_lua_ngx_exec(lua_State *L)
}
uri.data = ngx_palloc(r->pool, len);
+ if (uri.data == NULL) {
+ return luaL_error(L, "out of memory");
+ }
+
ngx_memcpy(uri.data, p, len);
uri.len = len;
@@ -91,6 +95,10 @@ ngx_http_lua_ngx_exec(lua_State *L)
p = (u_char *) lua_tolstring(L, 2, &len);
user_args.data = ngx_palloc(r->pool, len);
+ if (user_args.data == NULL) {
+ return luaL_error(L, "out of memory");
+ }
+
ngx_memcpy(user_args.data, p, len);
user_args.len = len;
View
@@ -50,6 +50,10 @@ ngx_http_lua_ngx_req_set_uri(lua_State *L)
}
r->uri.data = ngx_palloc(r->pool, len);
+ if (r->uri.data == NULL) {
+ return luaL_error(L, "out of memory");
+ }
+
ngx_memcpy(r->uri.data, p, len);
r->uri.len = len;
View
@@ -1791,7 +1791,7 @@ ngx_http_lua_process_args_option(ngx_http_request_t *r, lua_State *L,
dd("len 1: %d", (int) len);
p = ngx_palloc(r->pool, len);
- if (p == 0) {
+ if (p == NULL) {
luaL_error(L, "out of memory");
return;
}

0 comments on commit 29e8b41

Please sign in to comment.