From da03f0b57281b64008460226d1a77f78bde3f791 Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Mon, 21 Aug 2023 09:57:54 +0200 Subject: [PATCH] easy/file: fix file exists function This fixes a bug in the file exists function where it would return false positives for files that do not exist. --- lib/easy/file.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/easy/file.c b/lib/easy/file.c index 02f5338e7..159400463 100644 --- a/lib/easy/file.c +++ b/lib/easy/file.c @@ -52,16 +52,18 @@ sqsh_easy_file_exists(struct SqshArchive *archive, const char *path, int *err) { bool exists = false; rv = sqsh__tree_walker_init(&walker, archive); + if (rv < 0) { + goto out; + } + rv = sqsh_tree_walker_resolve(&walker, path, true); if (rv == -SQSH_ERROR_NO_SUCH_FILE) { rv = 0; goto out; } else if (rv < 0) { goto out; } - rv = sqsh_tree_walker_resolve(&walker, path, true); - if (rv < 0) { - goto out; - } + + exists = true; out: sqsh__tree_walker_cleanup(&walker);