From: P. F. Chimento Date: Sun, 13 Mar 2011 19:35:55 +0000 (+0100) Subject: Fix null pointer bug X-Git-Tag: v0.9~115 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=df5a5656a19699e1ea628f9149fe1b88ad3a0015;p=projects%2Fchimara%2Fchimara.git Fix null pointer bug Fixed a null pointer access in chimara_glk_set_css_from_file() when passing NULL as the error parameter. --- diff --git a/libchimara/chimara-glk.c b/libchimara/chimara-glk.c index ca01f44..4d8b552 100644 --- a/libchimara/chimara-glk.c +++ b/libchimara/chimara-glk.c @@ -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;