diff options
author | Monty <monty@mariadb.org> | 2022-05-04 17:30:21 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2022-06-06 14:12:20 +0300 |
commit | 392e744aec9e52802e7317f8c7f9b52019026ab9 (patch) | |
tree | e14537f0cfdcaeeb1a9aa2ab8c6876d3b6d74ddf | |
parent | 099b9202a5c0496cc4f4024a6e667fd526664f69 (diff) | |
download | mariadb-git-392e744aec9e52802e7317f8c7f9b52019026ab9.tar.gz |
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.
-rw-r--r-- | dbug/dbug.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/dbug/dbug.c b/dbug/dbug.c index 011b932a721..169dd226419 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -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) { |