Avoid a 'may be used uninitialized' warning when built with '-c opt'. (#15846)

The motivation for this is first that under some combinations of flags it breaks builds and second it's trivial (and possibly zero runtime cost) to fix.

It looks like the possibly bad case "should never happen", but converting this to a null pointer in the error case (which should at least make the failure less problematic) is cheap.

Closes #15846

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/15846 from bcsgh:bcsgh/uninitialized 321d649b51
PiperOrigin-RevId: 607404168
pull/15831/head
bcsgh 1 year ago committed by Copybara-Service
parent a938b595c2
commit eb70b343aa
  1. 2
      src/google/protobuf/arena.cc

@ -193,7 +193,7 @@ SizedPtr SerialArena::Free(Deallocator deallocator) {
PROTOBUF_NOINLINE
void* SerialArena::AllocateAlignedFallback(size_t n) {
AllocateNewBlock(n);
void* ret;
void* ret = nullptr;
bool res = MaybeAllocateAligned(n, &ret);
ABSL_DCHECK(res);
return ret;

Loading…
Cancel
Save