Skip to content

Commit

Permalink
Pacify address sanitizer on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
isanych committed Feb 5, 2025
1 parent 92f8c5b commit cef75ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/google/protobuf/dynamic_message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,10 @@ class DynamicMessage final : public Message {
// class's memory is allocated via the global operator new. Thus, we need to
// manually call the global operator delete. Calling the destructor is taken
// care of for us. This makes DynamicMessage compatible with -fsized-delete.
// It doesn't work for MSVC though.
#ifndef _MSC_VER
// Working in MSVC 19.30+ (MSVS 2022), may not work in old versions though.
#if !defined(_MSC_VER) || (_MSC_VER >= 1930)
static void operator delete(void* ptr) { ::operator delete(ptr); }
#endif // !_MSC_VER
#endif // !defined(_MSC_VER) || (_MSC_VER >= 1930)
#endif

private:
Expand Down
3 changes: 2 additions & 1 deletion src/google/protobuf/extension_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,8 @@ void ExtensionSet::Extension::Free() {
if (is_lazy) {
delete ptr.lazymessage_value;
} else {
delete ptr.message_value;
ptr.message_value->~MessageLite();
::operator delete(ptr.message_value);
}
break;
default:
Expand Down

0 comments on commit cef75ef

Please sign in to comment.