summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-04-08 12:04:33 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-06-07 14:35:40 +0200
commit7a2e1a0a7a575c64eaf050c8ec08e5b36e4acfad (patch)
treec3fda7a6c0202341612fd1ab489974abe2ce7e00 /bin
parenta49a5bc6253883f8dab06d5bae7e5453008da164 (diff)
Fix: libsquashfs: add sqfs_free() function
On systems like Windows, the dynamic library and applications can easily end up being linked against different runtime libraries, so applications cannot be expected to be able to free() any malloc'd pointer that the library returns. This commit adds an sqfs_free function so the application can pass pointers back to the library to call the correct free() implementation. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin')
-rw-r--r--bin/rdsquashfs/dump_xattrs.c6
-rw-r--r--bin/rdsquashfs/restore_fstree.c6
-rw-r--r--bin/rdsquashfs/stat.c2
-rw-r--r--bin/sqfs2tar/xattr.c6
4 files changed, 10 insertions, 10 deletions
diff --git a/bin/rdsquashfs/dump_xattrs.c b/bin/rdsquashfs/dump_xattrs.c
index 93b0b01..9dbe437 100644
--- a/bin/rdsquashfs/dump_xattrs.c
+++ b/bin/rdsquashfs/dump_xattrs.c
@@ -95,7 +95,7 @@ int dump_xattrs(sqfs_xattr_reader_t *xattr, const sqfs_inode_generic_t *inode)
if (sqfs_xattr_reader_read_value(xattr, key, &value)) {
fputs("Error reading xattr value\n", stderr);
- free(key);
+ sqfs_free(key);
return -1;
}
@@ -112,8 +112,8 @@ int dump_xattrs(sqfs_xattr_reader_t *xattr, const sqfs_inode_generic_t *inode)
printf("\n");
}
- free(key);
- free(value);
+ sqfs_free(key);
+ sqfs_free(value);
}
return 0;
diff --git a/bin/rdsquashfs/restore_fstree.c b/bin/rdsquashfs/restore_fstree.c
index 3d536b6..57582c2 100644
--- a/bin/rdsquashfs/restore_fstree.c
+++ b/bin/rdsquashfs/restore_fstree.c
@@ -188,7 +188,7 @@ static int set_xattr(const char *path, sqfs_xattr_reader_t *xattr,
if (sqfs_xattr_reader_read_value(xattr, key, &value)) {
fputs("Error reading xattr value\n", stderr);
- free(key);
+ sqfs_free(key);
return -1;
}
@@ -199,8 +199,8 @@ static int set_xattr(const char *path, sqfs_xattr_reader_t *xattr,
key->key, path, strerror(errno));
}
- free(key);
- free(value);
+ sqfs_free(key);
+ sqfs_free(value);
if (ret)
return -1;
}
diff --git a/bin/rdsquashfs/stat.c b/bin/rdsquashfs/stat.c
index 049baae..a5aab60 100644
--- a/bin/rdsquashfs/stat.c
+++ b/bin/rdsquashfs/stat.c
@@ -172,7 +172,7 @@ int stat_file(const sqfs_tree_node_t *node)
idx->size + 1, idx->name,
idx->start_block, idx->index);
- free(idx);
+ sqfs_free(idx);
}
break;
}
diff --git a/bin/sqfs2tar/xattr.c b/bin/sqfs2tar/xattr.c
index 9a9ec82..abec4fb 100644
--- a/bin/sqfs2tar/xattr.c
+++ b/bin/sqfs2tar/xattr.c
@@ -68,13 +68,13 @@ int get_xattrs(const char *name, const sqfs_inode_generic_t *inode,
ret = sqfs_xattr_reader_read_value(xr, key, &value);
if (ret) {
sqfs_perror(name, "reading xattr value", ret);
- free(key);
+ sqfs_free(key);
goto fail;
}
ent = mkxattr(key, value);
- free(key);
- free(value);
+ sqfs_free(key);
+ sqfs_free(value);
if (ent == NULL)
goto fail;