builderparser: Be more robust
authorMatthias Clasen <mclasen@redhat.com>
Mon, 13 Dec 2021 19:44:40 +0000 (14:44 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 13 Dec 2021 20:09:48 +0000 (15:09 -0500)
If a document contains no useful content,
just say so instead of crashing.

tools/gtk-builder-tool-simplify.c

index bb8e1ebd625b0bb0bb107d41a270e59af867ffda..635b6332fab702baf10fef2d6efa0382cdf0d820 100644 (file)
@@ -2301,6 +2301,12 @@ simplify_file (const char *filename,
       return FALSE;
     }
 
+  if (data.root == NULL)
+    {
+      g_printerr (_("Can't parse ā€œ%sā€\n"), filename);
+      return FALSE;
+    }
+
   data.builder = gtk_builder_new ();
 
   if (data.convert3to4)