]> www.infradead.org Git - mtd-utils.git/commitdiff
jffsX-utils: jffs2reader: Fix potential null pointer dereference compiling warning...
authorZhihao Cheng <chengzhihao1@huawei.com>
Sun, 26 Jan 2025 06:42:00 +0000 (14:42 +0800)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Thu, 30 Jan 2025 17:30:16 +0000 (18:30 +0100)
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>
jffsX-utils/jffs2reader.c

index 87a2167512ca9172095c6871d424eb3090616679..548fc8d59b44e7d1f5604ea1f3cf511ce9bd0f3f 100644 (file)
@@ -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;