Author: carnold Date: Wed Jan 9 22:26:04 2008 New Revision: 610690 URL: http://svn.apache.org/viewvc?rev=610690&view=rev Log: LOGCXX-200: filename.c_str() invalidated before exec on VC 2008
Modified: logging/log4cxx/trunk/src/main/cpp/gzcompressaction.cpp logging/log4cxx/trunk/src/main/cpp/nteventlogappender.cpp logging/log4cxx/trunk/src/main/cpp/writerappender.cpp logging/log4cxx/trunk/src/main/cpp/zipcompressaction.cpp Modified: logging/log4cxx/trunk/src/main/cpp/gzcompressaction.cpp URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/gzcompressaction.cpp?rev=610690&r1=610689&r2=610690&view=diff ============================================================================== --- logging/log4cxx/trunk/src/main/cpp/gzcompressaction.cpp (original) +++ logging/log4cxx/trunk/src/main/cpp/gzcompressaction.cpp Wed Jan 9 22:26:04 2008 @@ -17,6 +17,7 @@ #include <log4cxx/rolling/gzcompressaction.h> #include <apr_thread_proc.h> +#include <apr_strings.h> #include <log4cxx/helpers/exception.h> using namespace log4cxx; @@ -71,7 +72,7 @@ int i = 0; args[i++] = "gzip"; args[i++] = "-c"; - args[i++] = source.getOSName().c_str(); + args[i++] = apr_pstrdup(pool, source.getOSName().c_str()); args[i++] = NULL; Modified: logging/log4cxx/trunk/src/main/cpp/nteventlogappender.cpp URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/nteventlogappender.cpp?rev=610690&r1=610689&r2=610690&view=diff ============================================================================== --- logging/log4cxx/trunk/src/main/cpp/nteventlogappender.cpp (original) +++ logging/log4cxx/trunk/src/main/cpp/nteventlogappender.cpp Wed Jan 9 22:26:04 2008 @@ -26,6 +26,7 @@ #include <log4cxx/helpers/stringhelper.h> #include <log4cxx/helpers/transcoder.h> #include <log4cxx/helpers/pool.h> +#include <apr_strings.h> using namespace log4cxx; using namespace log4cxx::spi; @@ -199,8 +200,10 @@ layout->format(oss, event, p); #if LOG4CXX_WCHAR_T_API LOG4CXX_ENCODE_WCHAR(s, oss); - const wchar_t* msgs[1]; - msgs[0] = s.c_str() ; + wchar_t* msgs = (wchar_t*) + apr_palloc((apr_pool_t*) p.getAPRPool(), (s.length() + 1) * sizeof(wchar_t)); + memcpy(msgs, s.data(), s.length() * sizeof(wchar_t)); + msgs[s.length()] = 0; BOOL bSuccess = ::ReportEventW( hEventLog, getEventType(event), @@ -209,12 +212,11 @@ pCurrentUserSID, 1, 0, - msgs, + (LPCWSTR*) &msgs, NULL); #else LOG4CXX_ENCODE_CHAR(s, oss); - const char* msgs[1]; - msgs[0] = s.c_str() ; + const char* msgs = apr_pstrdup((apr_pool_t*) pool.getAPRPool(), s.c_str()); BOOL bSuccess = ::ReportEventA( hEventLog, getEventType(event), @@ -223,7 +225,7 @@ pCurrentUserSID, 1, 0, - msgs, + &msgs, NULL); #endif Modified: logging/log4cxx/trunk/src/main/cpp/writerappender.cpp URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/writerappender.cpp?rev=610690&r1=610689&r2=610690&view=diff ============================================================================== --- logging/log4cxx/trunk/src/main/cpp/writerappender.cpp (original) +++ logging/log4cxx/trunk/src/main/cpp/writerappender.cpp Wed Jan 9 22:26:04 2008 @@ -208,10 +208,12 @@ layout->format(msg, event, p); { synchronized sync(mutex); - writer->write(msg, p); - if (immediateFlush) { - writer->flush(p); - } + if (writer != NULL) { + writer->write(msg, p); + if (immediateFlush) { + writer->flush(p); + } + } } } Modified: logging/log4cxx/trunk/src/main/cpp/zipcompressaction.cpp URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/zipcompressaction.cpp?rev=610690&r1=610689&r2=610690&view=diff ============================================================================== --- logging/log4cxx/trunk/src/main/cpp/zipcompressaction.cpp (original) +++ logging/log4cxx/trunk/src/main/cpp/zipcompressaction.cpp Wed Jan 9 22:26:04 2008 @@ -17,6 +17,7 @@ #include <log4cxx/rolling/zipcompressaction.h> #include <apr_thread_proc.h> +#include <apr_strings.h> #include <log4cxx/helpers/exception.h> using namespace log4cxx; @@ -55,11 +56,12 @@ if (stat != APR_SUCCESS) throw IOException(stat); const char** args = (const char**) - apr_palloc(pool, 4 *sizeof(*args)); + apr_palloc(pool, 5 *sizeof(*args)); int i = 0; args[i++] = "zip"; - args[i++] = destination.getOSName().c_str(); - args[i++] = source.getOSName().c_str(); + args[i++] = "-q"; + args[i++] = apr_pstrdup(pool, destination.getOSName().c_str()); + args[i++] = apr_pstrdup(pool, source.getOSName().c_str()); args[i++] = NULL; if (destination.exists(p)) {