utils: Fix unreachable NULL deref by adding assertion

Again this one is just in theory, but let's add an assertion.
This commit is contained in:
Colin Walters committed 2021-10-13 17:13:14 -04:00
1 parent f355482e1f
commit 54bf42c3e5
1 file changed
+5 -2
+5 -2
View File
@@ -82,10 +82,13 @@ ot_gfile_ensure_unlinked (GFile *path,
GCancellable *cancellable,
GError **error)
{
if (unlink (gs_file_get_path_cached (path)) != 0)
g_assert (path);
const char *pathc = gs_file_get_path_cached (path);
g_assert (pathc);
if (unlink (pathc) != 0)
{
if (errno != ENOENT)
return glnx_throw_errno_prefix (error, "unlink(%s)", gs_file_get_path_cached (path));
return glnx_throw_errno_prefix (error, "unlink(%s)", pathc);
}
return TRUE;
}