fix: address sanitizer failures (#956)
This commit is contained in:
parent
7ba2f7bc02
commit
e567cfc442
@ -45,6 +45,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <new>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -637,13 +638,21 @@ void (*g_new_hook)() = nullptr;
|
|||||||
|
|
||||||
_END_GOOGLE_NAMESPACE_
|
_END_GOOGLE_NAMESPACE_
|
||||||
|
|
||||||
void* operator new(size_t size) GOOGLE_GLOG_THROW_BAD_ALLOC {
|
void* operator new(size_t size, const std::nothrow_t&) noexcept {
|
||||||
if (GOOGLE_NAMESPACE::g_new_hook) {
|
if (GOOGLE_NAMESPACE::g_new_hook) {
|
||||||
GOOGLE_NAMESPACE::g_new_hook();
|
GOOGLE_NAMESPACE::g_new_hook();
|
||||||
}
|
}
|
||||||
return malloc(size);
|
return malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* operator new(size_t size) GOOGLE_GLOG_THROW_BAD_ALLOC {
|
||||||
|
void* p = ::operator new(size, std::nothrow);
|
||||||
|
if (p == nullptr) {
|
||||||
|
throw std::bad_alloc{};
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
void* operator new[](size_t size) GOOGLE_GLOG_THROW_BAD_ALLOC {
|
void* operator new[](size_t size) GOOGLE_GLOG_THROW_BAD_ALLOC {
|
||||||
return ::operator new(size);
|
return ::operator new(size);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2268,7 +2268,9 @@ static bool SendEmailInternal(const char*dest, const char *subject,
|
|||||||
}
|
}
|
||||||
sanitized_dests << s;
|
sanitized_dests << s;
|
||||||
}
|
}
|
||||||
dest = sanitized_dests.str().c_str();
|
// Avoid dangling reference
|
||||||
|
const std::string& tmp = sanitized_dests.str();
|
||||||
|
dest = tmp.c_str();
|
||||||
|
|
||||||
if ( use_logging ) {
|
if ( use_logging ) {
|
||||||
VLOG(1) << "Trying to send TITLE:" << subject
|
VLOG(1) << "Trying to send TITLE:" << subject
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user