diff options
author | culler <culler> | 2017-11-11 23:27:52 (GMT) |
---|---|---|
committer | culler <culler> | 2017-11-11 23:27:52 (GMT) |
commit | d5774cfad0b689b36352cc680217fa4e774e2f87 (patch) | |
tree | cbcdbc7f137b26174961101de5d5621c26bf8eb2 | |
parent | 30387673256f4e878597915770213625f8f83273 (diff) | |
download | tk-d5774cfad0b689b36352cc680217fa4e774e2f87.zip tk-d5774cfad0b689b36352cc680217fa4e774e2f87.tar.gz tk-d5774cfad0b689b36352cc680217fa4e774e2f87.tar.bz2 |
Fix [b24a7a877d]: Added test for NULL pointer in WmIconphotoCmd.
-rw-r--r-- | macosx/tkMacOSXWm.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 1f766c1..0e112b9 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -2348,8 +2348,8 @@ WmIconphotoCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Image tk_icon; - int i, width, height, isDefault = 0; + Tk_Image tk_icon; + int width, height, isDefault = 0; if (objc < 4) { Tcl_WrongNumArgs(interp, 2, objv, @@ -2377,15 +2377,23 @@ WmIconphotoCmd( } /*Get image and convert to NSImage that can be displayed as icon.*/ - tk_icon = Tk_GetImage(interp, winPtr, icon, NULL, NULL); - Tk_SizeOfImage(tk_icon, &width, &height); + tk_icon = Tk_GetImage(interp, tkwin, icon, NULL, NULL); + if (tk_icon == NULL) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "can't use \"%s\" as iconphoto: not a photo image", + icon)); + Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", NULL); + return TCL_ERROR; + } NSImage *newIcon; + Tk_SizeOfImage(tk_icon, &width, &height); newIcon = TkMacOSXGetNSImageWithTkImage(winPtr->display, tk_icon, width, height); - [NSApp setApplicationIconImage: newIcon]; - Tk_FreeImage(tk_icon); - + if (newIcon == NULL) { + return TCL_ERROR; + } + [NSApp setApplicationIconImage: newIcon]; return TCL_OK; } |