aboutsummaryrefslogtreecommitdiff
path: root/extras
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-28 15:22:17 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-28 15:22:17 +0100
commitf5f523c923531c55d397070ba4ee4f8a8f5f8a63 (patch)
tree31052ce7b8db7ae42685bd0aafaeb2ee9bcd72d1 /extras
parent84b190cac1253d7348a38900fc88d9ad0a0ff41c (diff)
Minor fix in file browser demo
- Make sure to release the inode returne by the dir reader - Check the path resolution return code in change_directory Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'extras')
-rw-r--r--extras/browse.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/extras/browse.c b/extras/browse.c
index 1b32135..5b27dc6 100644
--- a/extras/browse.c
+++ b/extras/browse.c
@@ -29,6 +29,7 @@ static sqfs_data_reader_t *data;
static void change_directory(const char *dirname)
{
sqfs_inode_generic_t *inode;
+ int ret;
if (dirname == NULL || *dirname == '/') {
free(working_dir);
@@ -38,8 +39,13 @@ static void change_directory(const char *dirname)
}
if (dirname != NULL) {
- sqfs_dir_reader_find_by_path(dr, working_dir,
- dirname, &inode);
+ ret = sqfs_dir_reader_find_by_path(dr, working_dir,
+ dirname, &inode);
+ if (ret != 0) {
+ printf("Error resolving '%s', error code %d\n",
+ dirname, ret);
+ return;
+ }
free(working_dir);
working_dir = inode;
@@ -452,6 +458,8 @@ static void cat_cmd(const char *filename)
fwrite(buffer, 1, diff, stdout);
offset += diff;
}
+
+ free(inode);
}
/*****************************************************************************/