[util.cpp#L216](https://github.com/bitcoin/bitcoin/blob/master/src/util.cpp#L216) 
if `fopen `failed, a null file pointer could be passed to `FileWriteStr(vMsgsBeforeOpenLog->front(), fileout);`
{
    
    constexpr size_t RECENT_DEBUG_HISTORY_SIZE = 10 * 1000000;
    
    boost::filesystem::path pathLog = GetDataDir() / "debug.log";
    FILE* file = fopen(pathLog.string().c_str(), "r");
    
    
    if (file && boost::filesystem::file_size(pathLog) > 11 * (RECENT_DEBUG_HISTORY_SIZE / 10))
    {
        
        std::vector<char> vch(RECENT_DEBUG_HISTORY_SIZE, 0);
        fseek(file, -((long)vch.size()), SEEK_END);
        int nBytes = fread(vch.data(), 1, vch.size(), file);
        fclose(file);
        file = fopen(pathLog.string().c_str(), "w");
        if (file)
        {
            fwrite(vch.data(), 1, nBytes, file);
            fclose(file);
        }
    }
    else if (file != NULL)
        fclose(file);
}
#ifdef WIN32
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate)