utils: Fix unreachable `NULL` deref by adding assertion
authorColin Walters <walters@verbum.org>
Fri, 8 Oct 2021 13:10:59 +0000 (09:10 -0400)
committerColin Walters <walters@verbum.org>
Wed, 13 Oct 2021 21:13:14 +0000 (17:13 -0400)
Again this one is just in theory, but let's add an assertion.

src/libotutil/ot-gio-utils.c

index f09ee8af4f8631c84f5c13df76009d41f9c3efc1..9ee6f7d504aba5ff3f47aac998e20c1d140e1a1a 100644 (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;
 }