Skip to content

Commit

Permalink
Merge pull request #5 from CoolDesert/dev
Browse files Browse the repository at this point in the history
fix seristring memory leak
  • Loading branch information
cloudwu committed Jul 29, 2016
2 parents 59c1cd3 + 47e0bdb commit e591af4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions serialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,10 +741,14 @@ ldeserialize(lua_State *L) {

static int
seristring(lua_State *L) {
lpack(L);
lua_replace(L, 1);
lua_settop(L, 1);
struct write_block b;
wb_init(&b, NULL);
pack_from(L,&b,0);
struct block * ret = wb_close(&b);
lua_settop(L,0);
lua_pushlightuserdata(L,ret);
lserialize(L);
wb_free(&b);
void *buffer = lua_touserdata(L, -2);
int sz = lua_tointeger(L, -1);
lua_pushlstring(L, buffer, sz);
Expand Down

0 comments on commit e591af4

Please sign in to comment.