From eb70b343aab7584ed164a6ab4b39789427d0474f Mon Sep 17 00:00:00 2001 From: bcsgh <33939446+bcsgh@users.noreply.github.com> Date: Thu, 15 Feb 2024 11:42:19 -0800 Subject: [PATCH] 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 321d649b519bae91c90cdebfb90a6655d9c301cd PiperOrigin-RevId: 607404168 --- src/google/protobuf/arena.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc index bc162e984459..170d004c96b1 100644 --- a/src/google/protobuf/arena.cc +++ b/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;