Fix null pointer bug
[projects/chimara/chimara.git] / libchimara / chimara-glk.c
index ca01f44510d7c7dd86a0db2fa9698385cea1197b..4d8b55249fd6b3f2136e3daf9e34141481b10bee 100644 (file)
@@ -1063,8 +1063,9 @@ chimara_glk_set_css_from_file(ChimaraGlk *glk, const gchar *filename, GError **e
 
        int fd = open(filename, O_RDONLY);
        if(fd == -1) {
-               *error = g_error_new(G_IO_ERROR, g_io_error_from_errno(errno), 
-                   _("Error opening file \"%s\": %s"), filename, g_strerror(errno));
+               if(error)
+                       *error = g_error_new(G_IO_ERROR, g_io_error_from_errno(errno), 
+                               _("Error opening file \"%s\": %s"), filename, g_strerror(errno));
                return FALSE;
        }
 
@@ -1074,8 +1075,9 @@ chimara_glk_set_css_from_file(ChimaraGlk *glk, const gchar *filename, GError **e
        scan_css_file(scanner, glk);
 
        if(close(fd) == -1) {
-               *error = g_error_new(G_IO_ERROR, g_io_error_from_errno(errno),
-                   _("Error closing file \"%s\": %s"), filename, g_strerror(errno));
+               if(error)
+                       *error = g_error_new(G_IO_ERROR, g_io_error_from_errno(errno),
+                               _("Error closing file \"%s\": %s"), filename, g_strerror(errno));
                return FALSE;
        }
        return TRUE;