sudo/backport-Fix-a-clang-analyzer-14-warning-about-a-possible-NUL.patch

27 lines
940 B
Diff
Raw Normal View History

From bfc6249902d842626058e74074832930feaf2f80 Mon Sep 17 00:00:00 2001
From: "Todd C. Miller" <Todd.Miller@sudo.ws>
Date: Wed, 29 Jun 2022 11:18:16 -0600
Subject: [PATCH] Fix a clang analyzer 14 warning about a possible NULL deref.
---
lib/protobuf-c/protobuf-c.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/protobuf-c/protobuf-c.c b/lib/protobuf-c/protobuf-c.c
index 3cc22c5f0..9ee355df5 100644
--- a/lib/protobuf-c/protobuf-c.c
+++ b/lib/protobuf-c/protobuf-c.c
@@ -3246,6 +3246,9 @@ protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc,
/* allocate space for repeated fields, also check that all required fields have been set */
for (f = 0; f < desc->n_fields; f++) {
const ProtobufCFieldDescriptor *field = desc->fields + f;
+ if (field == NULL) {
+ continue;
+ }
if (field->label == PROTOBUF_C_LABEL_REPEATED) {
size_t siz =
sizeof_elt_in_repeated_array(field->type);
--
2.33.0