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.
This commit is contained in:
Monty 2022-05-04 17:30:21 +03:00
parent 099b9202a5
commit 392e744aec

View file

@ -1994,11 +1994,10 @@ static void DBUGOpenFile(CODE_STATE *cs,
static void DBUGCloseFile(CODE_STATE *cs, sFILE *new_value)
{
sFILE *fp;
if (!cs || !cs->stack || !cs->stack->out_file)
if (!cs || !cs->stack || !(fp= cs->stack->out_file))
return;
fp= cs->stack->out_file;
if (--fp->used == 0)
if (fp != sstdout && fp != sstderr && --fp->used == 0)
{
if (fclose(fp->file) == EOF)
{