Skip to content

Commit

Permalink
Fix occasional luac.cross crash (#2661)
Browse files Browse the repository at this point in the history
A block of memory is accessed after having been freed. This was obscured by the fact that 'oBuf' is a pointer into the middle of the block 'dynamicTables', so when dynamicTables is freed, oBuf is pointing to freed memory. Occasionally, luac.cross would crash because of this.
  • Loading branch information
ziggurat29 authored and marcelstoer committed Feb 12, 2019
1 parent f0a240a commit 0c7758a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/uzlib/uzlib_deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,6 @@ int uzlib_compress (uchar **dest, uint *destLen, const uchar *src, uint srcLen)
status = UZLIB_OK;
}

FREE(dynamicTables);
for (i=0; i<20;i++) DBG_PRINT("count %u = %u\n",i,debugCounts[i]);

if (status == UZLIB_OK) {
Expand All @@ -581,5 +580,7 @@ int uzlib_compress (uchar **dest, uint *destLen, const uchar *src, uint srcLen)
FREE(oBuf->buffer);
}

FREE(dynamicTables);

return status;
}

0 comments on commit 0c7758a

Please sign in to comment.