]> spindle.queued.net Git - midori/commitdiff
Only set error in midori_array_from_file if it is not NULL
authorChristian Dywan <christian@twotoasts.de>
Fri, 28 Aug 2009 21:50:09 +0000 (23:50 +0200)
committerChristian Dywan <christian@twotoasts.de>
Fri, 28 Aug 2009 23:23:10 +0000 (01:23 +0200)
midori/midori-array.c

index 9319536614c50f7138d778c0b990dadc95e0240c..4ea123b2c33fdc8aea2916fb43477f39c3276fce 100644 (file)
@@ -246,16 +246,18 @@ midori_array_from_file (KatzeArray*  array,
     if (!g_file_test (filename, G_FILE_TEST_EXISTS))
     {
         /* File doesn't exist */
-        *error = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_NOENT,
-                                      _("File not found."));
+        if (error)
+            *error = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_NOENT,
+                                          _("File not found."));
         return FALSE;
     }
 
     if ((doc = xmlParseFile (filename)) == NULL)
     {
         /* No valid xml or broken encoding */
-        *error = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_FAILED,
-                                      _("Malformed document."));
+        if (error)
+            *error = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                                          _("Malformed document."));
         return FALSE;
     }
 
@@ -263,8 +265,9 @@ midori_array_from_file (KatzeArray*  array,
     {
         /* Parsing failed */
         xmlFreeDoc (doc);
-        *error = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_FAILED,
-                                      _("Malformed document."));
+        if (error)
+            *error = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                                          _("Malformed document."));
         return FALSE;
     }
     xmlFreeDoc (doc);