From df5a5656a19699e1ea628f9149fe1b88ad3a0015 Mon Sep 17 00:00:00 2001 From: "P. F. Chimento" Date: Sun, 13 Mar 2011 20:35:55 +0100 Subject: [PATCH] Fix null pointer bug Fixed a null pointer access in chimara_glk_set_css_from_file() when passing NULL as the error parameter. --- libchimara/chimara-glk.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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; -- 2.30.2