1
0
forked from boostorg/core

Added a check for NULL pointer in fclose_deleter.

The deleter can be called on a null pointer by shared_ptr.

Also added tests with unique_ptr from Boost.Move and shared_ptr
from Boost.SmartPtr.
This commit is contained in:
Andrey Semashev
2022-09-21 18:09:42 +03:00
parent 3510f6244b
commit 00f4f11f14
3 changed files with 30 additions and 8 deletions

View File

@@ -36,7 +36,8 @@ struct fclose_deleter
*/
void operator() (std::FILE* p) const BOOST_NOEXCEPT
{
std::fclose(p);
if (BOOST_LIKELY(!!p))
std::fclose(p);
}
};