From 0cd1d25438f233de573cba45dd140331edef7287 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 3 Sep 2023 20:08:27 +0200 Subject: coverity: fix: potential null-pointer dereference Signed-off-by: David Oberhollenzer --- bin/sqfsdiff/src/extract.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'bin/sqfsdiff') diff --git a/bin/sqfsdiff/src/extract.c b/bin/sqfsdiff/src/extract.c index df74f0f..a5e21b7 100644 --- a/bin/sqfsdiff/src/extract.c +++ b/bin/sqfsdiff/src/extract.c @@ -18,10 +18,12 @@ static int extract(sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode, sprintf(temp, "%s/%s", prefix, path); ptr = strrchr(temp, '/'); - *ptr = '\0'; - if (mkdir_p(temp)) - return -1; - *ptr = '/'; + if (ptr != NULL) { + *ptr = '\0'; + if (mkdir_p(temp)) + return -1; + *ptr = '/'; + } ret = sqfs_ostream_open_file(&fp, temp, SQFS_FILE_OPEN_OVERWRITE); if (ret) { -- cgit v1.2.3