Skip to content

Commit

Permalink
lminiz: return nil on deflate/inflate failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilal2453 committed Aug 31, 2024
1 parent eb1d7c9 commit 1c8d77a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lminiz.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ static int ltinfl(lua_State* L) {
size_t out_len;
int flags = luaL_optinteger(L, 2, 0);
char* out_buf = tinfl_decompress_mem_to_heap(in_buf, in_len, &out_len, flags);
if (!out_buf) {
lua_pushnil(L);
lua_pushstring(L, "Problem inflating data into memory");
return 2;
}
lua_pushlstring(L, out_buf, out_len);
free(out_buf);
return 1;
Expand All @@ -351,6 +356,11 @@ static int ltdefl(lua_State* L) {
size_t out_len;
int flags = luaL_optinteger(L, 2, 0);
char* out_buf = tdefl_compress_mem_to_heap(in_buf, in_len, &out_len, flags);
if (!out_buf) {
lua_pushnil(L);
lua_pushstring(L, "Problem deflating data into memory");
return 2;
}
lua_pushlstring(L, out_buf, out_len);
free(out_buf);
return 1;
Expand Down

0 comments on commit 1c8d77a

Please sign in to comment.