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 2021-10-08 09:10:59 -04:00
parent f355482e1f
commit 54bf42c3e5

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;
}