protobuf-c/backport-0001-Fix-a-clang-analyzer-14-warning-about-a-possible-NUL.patch
mengwenhua fce33eaeb9 Fix a clang analyzer 14 warning about a possible NULL deref.
Signed-off-by: mengwenhua <mengwenhua@xfusion.com>
2023-01-07 15:40:30 +08:00

29 lines
1.0 KiB
Diff

From ab5f76a52bade28a2c025bd52c7847f033ca82f3 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.
[edmonds: Import commit from
https://github.com/sudo-project/sudo/commit/bfc6249902d842626058e74074832930feaf2f80.patch.]
---
protobuf-c/protobuf-c.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/protobuf-c/protobuf-c.c b/protobuf-c/protobuf-c.c
index 448f3e8..ad3ab12 100644
--- a/protobuf-c/protobuf-c.c
+++ b/protobuf-c/protobuf-c.c
@@ -3231,6 +3231,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.37.3.windows.1