aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/sqfsdiff/src/extract.c10
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) {