Index: ext/libicpf/src/libicpf/log.cpp =================================================================== diff -u -N -rf1b06fb5cb28c288447c8aa69dccfca82179f6e7 -r361d7f8b9268e18f39e298ea82425f7ddb24fb43 --- ext/libicpf/src/libicpf/log.cpp (.../log.cpp) (revision f1b06fb5cb28c288447c8aa69dccfca82179f6e7) +++ ext/libicpf/src/libicpf/log.cpp (.../log.cpp) (revision 361d7f8b9268e18f39e298ea82425f7ddb24fb43) @@ -103,6 +103,8 @@ int_t log_file::size() const { assert(m_pszPath); + if(!m_pszPath) + return -1; int_t iSize=-1; FILE* pFile=_tfopen(m_pszPath, _t("r")); @@ -126,7 +128,9 @@ bool log_file::truncate(int_t iAdd) const { assert(m_pszPath); - + if(!m_pszPath) + return false; + // if we doesn't need to truncate anything if (m_iMaxSize <= 0) return true; @@ -296,9 +300,11 @@ void log_file::logs(int_t iType, bool bStd, const tchar_t* pszStr) { assert(m_pszPath); - - if (iType < m_iLogLevel) + if(!m_pszPath) return; + + if (iType < m_iLogLevel || iType < 0 || iType >= sizeof(__logtype_str)) + return; // log time time_t t=time(NULL); @@ -571,7 +577,8 @@ // format a string with err no and desc tchar_t szError[1024]; - _sntprintf(szError, 1024, _t("0x%lx (%s)"), iSysErr, pszErrDesc); + _sntprintf(szError, 1023, _t("0x%lx (%s)"), iSysErr, pszErrDesc); + szError[1023] = _T('\0'); // replace %err with the new data pszOut[0]=_t('\0');