diff options
author | culler <culler> | 2019-11-09 14:49:43 (GMT) |
---|---|---|
committer | culler <culler> | 2019-11-09 14:49:43 (GMT) |
commit | 1ba2cee840613a4386f80189fce4169061cc6f40 (patch) | |
tree | 1f252071d23f005d25411b8abcfbe4818523a4b3 | |
parent | f51d73def011d920a123d35863c79a9c0e253016 (diff) | |
download | tk-1ba2cee840613a4386f80189fce4169061cc6f40.zip tk-1ba2cee840613a4386f80189fce4169061cc6f40.tar.gz tk-1ba2cee840613a4386f80189fce4169061cc6f40.tar.bz2 |
Fix [53d28027e3]: Generate an error instead of a crash if wm iconphoto receives an invalid photo image.
-rw-r--r-- | macosx/tkMacOSXDraw.c | 7 | ||||
-rw-r--r-- | macosx/tkMacOSXWm.c | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 5714bf4..3f7ca0a 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -501,9 +501,12 @@ TkMacOSXGetNSImageWithTkImage( int width, int height) { - Pixmap pixmap = Tk_GetPixmap(display, None, width, height, 0); + Pixmap pixmap; NSImage *nsImage; - + if (width == 0 | height == 0) { + return NULL; + } + pixmap = Tk_GetPixmap(display, None, width, height, 0); Tk_RedrawImage(image, 0, 0, width, height, pixmap, 0, 0); nsImage = CreateNSImageWithPixmap(pixmap, width, height); Tk_FreePixmap(display, pixmap); diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index c2b67f6..40fca11 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -2569,6 +2569,10 @@ WmIconphotoCmd( width, height); Tk_FreeImage(tk_icon); if (newIcon == NULL) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "Failed to create an NSImage from \"%s\".", + icon)); + Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", NULL); return TCL_ERROR; } [NSApp setApplicationIconImage: newIcon]; |