Skip to content

Commit 392e744

Browse files
committed
Fixed crashing when using DBUG_PUSH_EMPTY
DBUG_PUSH_EMPTY is used by thr_mutex.cc. If there are 4G of DBUG_PUSH_EMPTY calls, then DBUG_POP_EMPTY will cause a crash when DBUGCloseFile() will try to free an object that was never allocated.
1 parent 099b920 commit 392e744

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

dbug/dbug.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,11 +1994,10 @@ static void DBUGOpenFile(CODE_STATE *cs,
19941994
static void DBUGCloseFile(CODE_STATE *cs, sFILE *new_value)
19951995
{
19961996
sFILE *fp;
1997-
if (!cs || !cs->stack || !cs->stack->out_file)
1997+
if (!cs || !cs->stack || !(fp= cs->stack->out_file))
19981998
return;
19991999

2000-
fp= cs->stack->out_file;
2001-
if (--fp->used == 0)
2000+
if (fp != sstdout && fp != sstderr && --fp->used == 0)
20022001
{
20032002
if (fclose(fp->file) == EOF)
20042003
{

0 commit comments

Comments
 (0)