[gimp] Bug 793951 - Fix crashes when some external APIs fail
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 793951 - Fix crashes when some external APIs fail
- Date: Mon, 26 Mar 2018 19:28:02 +0000 (UTC)
commit a6fd24a953655e3e65f797bfde56da5177a4c768
Author: Zhouyang <jiazhouyang09 gmail com>
Date: Mon Mar 26 21:25:10 2018 +0200
Bug 793951 - Fix crashes when some external APIs fail
Check the return values of some functions and set errors or print
a message to stderr if they fail.
app/display/gimpdisplayshell-layer-select.c | 11 +++++++----
plug-ins/common/file-png.c | 14 ++++++++++++++
plug-ins/common/file-xpm.c | 3 +++
3 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-layer-select.c b/app/display/gimpdisplayshell-layer-select.c
index 0b52dcb..023bf1d 100644
--- a/app/display/gimpdisplayshell-layer-select.c
+++ b/app/display/gimpdisplayshell-layer-select.c
@@ -75,9 +75,10 @@ gimp_display_shell_layer_select_init (GimpDisplayShell *shell,
gint move,
guint32 time)
{
- LayerSelect *layer_select;
- GimpImage *image;
- GimpLayer *layer;
+ LayerSelect *layer_select;
+ GimpImage *image;
+ GimpLayer *layer;
+ GdkGrabStatus status;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
@@ -97,7 +98,9 @@ gimp_display_shell_layer_select_init (GimpDisplayShell *shell,
gtk_widget_show (layer_select->window);
- gdk_keyboard_grab (gtk_widget_get_window (layer_select->window), FALSE, time);
+ status = gdk_keyboard_grab (gtk_widget_get_window (layer_select->window), FALSE, time);
+ if (status != GDK_GRAB_SUCCESS)
+ g_printerr ("gdk_keyboard_grab failed with status %d\n", status);
}
diff --git a/plug-ins/common/file-png.c b/plug-ins/common/file-png.c
index 2d43973..4619fdd 100644
--- a/plug-ins/common/file-png.c
+++ b/plug-ins/common/file-png.c
@@ -888,6 +888,13 @@ load_image (const gchar *filename,
}
info = png_create_info_struct (pp);
+ if (! info)
+ {
+ g_set_error (error, 0, 0,
+ _("Error while reading '%s'. Could not create PNG header info structure."),
+ gimp_filename_to_utf8 (filename));
+ return -1;
+ }
if (setjmp (png_jmpbuf (pp)))
{
@@ -1537,6 +1544,13 @@ save_image (const gchar *filename,
}
info = png_create_info_struct (pp);
+ if (! info)
+ {
+ g_set_error (error, 0, 0,
+ _("Error while exporting '%s'. Could not create PNG header info structure."),
+ gimp_filename_to_utf8 (filename));
+ return FALSE;
+ }
if (setjmp (png_jmpbuf (pp)))
{
diff --git a/plug-ins/common/file-xpm.c b/plug-ins/common/file-xpm.c
index 5d85ab2..b5b7967 100644
--- a/plug-ins/common/file-xpm.c
+++ b/plug-ins/common/file-xpm.c
@@ -408,6 +408,9 @@ parse_colors (XpmImage *xpm_image)
#ifndef XPM_NO_X
/* open the display and get the default color map */
display = XOpenDisplay (NULL);
+ if (display == NULL)
+ g_printerr ("Could not open display\n");
+
colormap = DefaultColormap (display, DefaultScreen (display));
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]