Fix possible leaks in stdext::format
This commit is contained in:
parent
dcd6249e8f
commit
cf77df05ca
|
@ -55,7 +55,7 @@ bool ResourceManager::discoverWorkDir(const std::string& existentFile)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(PHYSFS_exists(existentFile.c_str())) {
|
if(PHYSFS_exists(existentFile.c_str())) {
|
||||||
g_logger.debug(stdext::format("Found work dir at '%s'", dir.c_str()));
|
g_logger.debug(stdext::format("Found work dir at '%s'", dir));
|
||||||
m_workDir = dir;
|
m_workDir = dir;
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -111,7 +111,7 @@ void crashHandler(int signum, siginfo_t* info, void* secret)
|
||||||
fout << ss.str();
|
fout << ss.str();
|
||||||
fout << "\n";
|
fout << "\n";
|
||||||
fout.close();
|
fout.close();
|
||||||
g_logger.info(stdext::format("Crash report saved to file %s", fileName.c_str()));
|
g_logger.info(stdext::format("Crash report saved to file %s", fileName));
|
||||||
} else
|
} else
|
||||||
g_logger.error("Failed to save crash report!");
|
g_logger.error("Failed to save crash report!");
|
||||||
|
|
||||||
|
|
|
@ -111,13 +111,13 @@ LONG CALLBACK ExceptionHandler(LPEXCEPTION_POINTERS e)
|
||||||
SymInitialize(GetCurrentProcess(), 0, TRUE);
|
SymInitialize(GetCurrentProcess(), 0, TRUE);
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "== application crashed\n";
|
ss << "== application crashed\n";
|
||||||
ss << stdext::format("app name: %s\n", g_app.getName().c_str());
|
ss << stdext::format("app name: %s\n", g_app.getName());
|
||||||
ss << stdext::format("app version: %s\n", g_app.getVersion().c_str());
|
ss << stdext::format("app version: %s\n", g_app.getVersion());
|
||||||
ss << stdext::format("build compiler: %s\n", BUILD_COMPILER);
|
ss << stdext::format("build compiler: %s\n", BUILD_COMPILER);
|
||||||
ss << stdext::format("build date: %s\n", __DATE__);
|
ss << stdext::format("build date: %s\n", __DATE__);
|
||||||
ss << stdext::format("build type: %s\n", BUILD_TYPE);
|
ss << stdext::format("build type: %s\n", BUILD_TYPE);
|
||||||
ss << stdext::format("build revision: %s (%s)\n", BUILD_REVISION, BUILD_COMMIT);
|
ss << stdext::format("build revision: %s (%s)\n", BUILD_REVISION, BUILD_COMMIT);
|
||||||
ss << stdext::format("crash date: %s\n", stdext::date_time_string().c_str());
|
ss << stdext::format("crash date: %s\n", stdext::date_time_string());
|
||||||
ss << stdext::format("exception: %s (0x%08lx)\n", getExceptionName(e->ExceptionRecord->ExceptionCode), e->ExceptionRecord->ExceptionCode);
|
ss << stdext::format("exception: %s (0x%08lx)\n", getExceptionName(e->ExceptionRecord->ExceptionCode), e->ExceptionRecord->ExceptionCode);
|
||||||
ss << stdext::format("exception address: 0x%08lx\n", (long unsigned int)e->ExceptionRecord->ExceptionAddress);
|
ss << stdext::format("exception address: 0x%08lx\n", (long unsigned int)e->ExceptionRecord->ExceptionAddress);
|
||||||
ss << stdext::format(" backtrace:\n");
|
ss << stdext::format(" backtrace:\n");
|
||||||
|
|
|
@ -236,7 +236,7 @@ void WIN32Window::terminate()
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_instance) {
|
if(m_instance) {
|
||||||
if(!UnregisterClassA(g_app.getCompactName().c_str(), m_instance))
|
if(!UnregisterClassA(g_app.getCompactName(), m_instance))
|
||||||
g_logger.error("UnregisterClassA failed");
|
g_logger.error("UnregisterClassA failed");
|
||||||
m_instance = NULL;
|
m_instance = NULL;
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ void WIN32Window::internalCreateWindow()
|
||||||
wc.hCursor = m_defaultCursor;
|
wc.hCursor = m_defaultCursor;
|
||||||
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||||
wc.lpszMenuName = NULL;
|
wc.lpszMenuName = NULL;
|
||||||
wc.lpszClassName = g_app.getCompactName().c_str();
|
wc.lpszClassName = g_app.getCompactName();
|
||||||
|
|
||||||
if(!RegisterClassA(&wc))
|
if(!RegisterClassA(&wc))
|
||||||
g_logger.fatal("Failed to register the window class.");
|
g_logger.fatal("Failed to register the window class.");
|
||||||
|
|
|
@ -48,6 +48,7 @@ typename std::enable_if<std::is_integral<T>::value ||
|
||||||
std::is_pointer<T>::value ||
|
std::is_pointer<T>::value ||
|
||||||
std::is_floating_point<T>::value ||
|
std::is_floating_point<T>::value ||
|
||||||
std::is_enum<T>::value, T>::type sprintf_cast(const T& t) { return t; }
|
std::is_enum<T>::value, T>::type sprintf_cast(const T& t) { return t; }
|
||||||
|
inline const char *sprintf_cast(const char *s) { return s; }
|
||||||
inline const char *sprintf_cast(const std::string& s) { return s.c_str(); }
|
inline const char *sprintf_cast(const std::string& s) { return s.c_str(); }
|
||||||
|
|
||||||
template<int N> struct expand_snprintf {
|
template<int N> struct expand_snprintf {
|
||||||
|
|
|
@ -536,7 +536,7 @@ void UIWidget::applyStyle(const OTMLNodePtr& styleNode)
|
||||||
for(const OTMLNodePtr& node : styleNode->children()) {
|
for(const OTMLNodePtr& node : styleNode->children()) {
|
||||||
if(node->tag()[0] == '!') {
|
if(node->tag()[0] == '!') {
|
||||||
std::string tag = node->tag().substr(1);
|
std::string tag = node->tag().substr(1);
|
||||||
std::string code = stdext::format("tostring(%s)", node->value().c_str());
|
std::string code = stdext::format("tostring(%s)", node->value());
|
||||||
std::string origin = "@" + node->source() + ": [" + node->tag() + "]";
|
std::string origin = "@" + node->source() + ": [" + node->tag() + "]";
|
||||||
g_lua.evaluateExpression(code, origin);
|
g_lua.evaluateExpression(code, origin);
|
||||||
std::string value = g_lua.popString();
|
std::string value = g_lua.popString();
|
||||||
|
|
Loading…
Reference in New Issue