Only set error in midori_array_from_file if it is not NULL

This commit is contained in:
Christian Dywan 2009-08-28 23:50:09 +02:00
parent 1efc9d4488
commit e3b27cb70d

View file

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