From: Zhihao Cheng <chengzhihao1@huawei.com>
Date: Sun, 26 Jan 2025 06:42:00 +0000 (+0800)
Subject: jffsX-utils: jffs2reader: Fix potential null pointer dereference compiling warning... 
X-Git-Tag: v2.3.0~5
X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=8e8697a4ee2edbc14f16720613cbf408d70eb895;p=mtd-utils.git

jffsX-utils: jffs2reader: Fix potential null pointer dereference compiling warning for 'path'

The compiler compains following message:
 jffsX-utils/jffs2reader.c:697:6: warning: potential null pointer
 dereference
It won't bring any problems because the 'path' is guaranteed to be a
non-NULL variable. Fix the warning by adding a NULL pointer check.

Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---

diff --git a/jffsX-utils/jffs2reader.c b/jffsX-utils/jffs2reader.c
index 87a2167..548fc8d 100644
--- a/jffsX-utils/jffs2reader.c
+++ b/jffsX-utils/jffs2reader.c
@@ -694,6 +694,9 @@ static struct jffs2_raw_dirent *resolvepath0(char *o, size_t size, uint32_t ino,
 
 	pp = path = xstrdup(p);
 
+	if (path == NULL)
+		return NULL;
+
 	if (*path == '/') {
 		path++;
 		ino = 1;