diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-09-03 20:08:27 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-09-03 20:08:27 +0200 |
commit | 0cd1d25438f233de573cba45dd140331edef7287 (patch) | |
tree | ef3d665f1ff0ef2b7b9561eff8c5f7d04bd0fcbd /bin/sqfsdiff/src | |
parent | 587759c6f26ab0b64f0baf1c03587d4f08042817 (diff) |
coverity: fix: potential null-pointer dereference
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/sqfsdiff/src')
-rw-r--r-- | bin/sqfsdiff/src/extract.c | 10 |
1 files changed, 6 insertions, 4 deletions
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) { |