Bug#368461: libc6: malloc_stats sets stderr NOTCANCEL flag, but doesn't clear it
Package: libc6
Version: 2.3.6-7
Severity: normal
./malloc/malloc.c malloc_stats() backend mSTATs() does:
|#ifdef _LIBC
| _IO_flockfile (stderr);
| int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
| ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
|#endif
|
|[...]
|
|#ifdef _LIBC
| ((_IO_FILE *) stderr)->_flags2 |= old_flags2;
| _IO_funlockfile (stderr);
|#endif
This doesn't make sense; stderr->_flags2 gets NOTCANCEL set, and
oldflags possibly has it unset. It seems that the intent is to
restore the old state of stderr->_flags2, but that isn't what happens.
The second |= is, as written, a NOP.
Perhaps the intent is to use:
| ((_IO_FILE *) stderr)->_flags2 &= old_flags2;
Which will clear the NOTCANCEL flag if it was not set at the beginning
of the function. This is still a roundabout way of assigning a value,
but perhaps other flags get changed at other layers of code, too..
Reply to: