Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bugfix: now we use lua userdata to allocate memory used on the C side…

… to prevent potential leaks caused by malloc/free, as discussed in github issue #6.
  • Loading branch information...
commit 0dfb28185f663d50fbfa3bbb15ba61d54274282d 1 parent 32cee57
@agentzh agentzh authored
Showing with 1 addition and 6 deletions.
  1. +1 −6 redis-parser.c
View
7 redis-parser.c
@@ -586,10 +586,7 @@ redis_build_query(lua_State *L)
}
}
- buf = malloc(total);
- if (buf == NULL) {
- return luaL_error(L, "out of memory");
- }
+ buf = lua_newuserdata(L, total); /* lua_newuserdata never returns NULL */
last = buf;
@@ -647,8 +644,6 @@ redis_build_query(lua_State *L)
lua_pushlstring(L, buf, total);
- free(buf);
-
return 1;
}
Please sign in to comment.
Something went wrong with that request. Please try again.