summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-12-11 09:49:13 -0500
committerDavid Robillard <d@drobilla.net>2024-12-11 10:06:33 -0500
commit09bfde1eb9b70cd32b8ca3c1cc9742d661277e3d (patch)
tree61c3764fac49ed8623cd56c821804cd00e5be374 /src
parent158e199d0dbc54fe497a53b167c880a8c85a9017 (diff)
downloadzix-09bfde1eb9b70cd32b8ca3c1cc9742d661277e3d.tar.gz
zix-09bfde1eb9b70cd32b8ca3c1cc9742d661277e3d.tar.bz2
zix-09bfde1eb9b70cd32b8ca3c1cc9742d661277e3d.zip
Fix potential null dereferences
Diffstat (limited to 'src')
-rw-r--r--src/path.c2
-rw-r--r--src/win32/filesystem_win32.c4
2 files changed, 4 insertions, 2 deletions
diff --git a/src/path.c b/src/path.c
index 8d68781..7e67af6 100644
--- a/src/path.c
+++ b/src/path.c
@@ -697,7 +697,7 @@ zix_path_is_absolute(const char* const path)
{
#ifdef _WIN32
const ZixRootSlices root = zix_path_root_slices(path);
- return (!zix_is_empty_range(root.name) &&
+ return (path && !zix_is_empty_range(root.name) &&
(!zix_is_empty_range(root.dir) ||
(is_dir_sep(path[0]) && is_dir_sep(path[1]))));
diff --git a/src/win32/filesystem_win32.c b/src/win32/filesystem_win32.c
index 21bb94e..24ba427 100644
--- a/src/win32/filesystem_win32.c
+++ b/src/win32/filesystem_win32.c
@@ -365,7 +365,9 @@ zix_file_type(const char* const path)
// Resolve symlink to find the canonical type
char* const canonical = zix_canonical_path(NULL, path);
- const ZixFileType real_type = zix_symlink_type(canonical);
+ const ZixFileType real_type =
+ canonical ? zix_symlink_type(canonical) : ZIX_FILE_TYPE_NONE;
+
zix_free(NULL, canonical);
return real_type;
}