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.
This commit is contained in:

committed by
Michael Natterer

parent
fae9c28354
commit
a6fd24a953
@ -75,9 +75,10 @@ gimp_display_shell_layer_select_init (GimpDisplayShell *shell,
|
|||||||
gint move,
|
gint move,
|
||||||
guint32 time)
|
guint32 time)
|
||||||
{
|
{
|
||||||
LayerSelect *layer_select;
|
LayerSelect *layer_select;
|
||||||
GimpImage *image;
|
GimpImage *image;
|
||||||
GimpLayer *layer;
|
GimpLayer *layer;
|
||||||
|
GdkGrabStatus status;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
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);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -888,6 +888,13 @@ load_image (const gchar *filename,
|
|||||||
}
|
}
|
||||||
|
|
||||||
info = png_create_info_struct (pp);
|
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)))
|
if (setjmp (png_jmpbuf (pp)))
|
||||||
{
|
{
|
||||||
@ -1537,6 +1544,13 @@ save_image (const gchar *filename,
|
|||||||
}
|
}
|
||||||
|
|
||||||
info = png_create_info_struct (pp);
|
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)))
|
if (setjmp (png_jmpbuf (pp)))
|
||||||
{
|
{
|
||||||
|
@ -408,6 +408,9 @@ parse_colors (XpmImage *xpm_image)
|
|||||||
#ifndef XPM_NO_X
|
#ifndef XPM_NO_X
|
||||||
/* open the display and get the default color map */
|
/* open the display and get the default color map */
|
||||||
display = XOpenDisplay (NULL);
|
display = XOpenDisplay (NULL);
|
||||||
|
if (display == NULL)
|
||||||
|
g_printerr ("Could not open display\n");
|
||||||
|
|
||||||
colormap = DefaultColormap (display, DefaultScreen (display));
|
colormap = DefaultColormap (display, DefaultScreen (display));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user