diff options
author | das <das> | 2008-12-07 16:34:55 (GMT) |
---|---|---|
committer | das <das> | 2008-12-07 16:34:55 (GMT) |
commit | 3751f59aa906bc929c67d1f6099a118668cb8bfb (patch) | |
tree | 51c6425facf14768762c5181fc1e89586539e0a1 /generic/tkWindow.c | |
parent | a18af25907310bc2a5e74b4b5ffbc2a0f798a7f8 (diff) | |
download | tk-3751f59aa906bc929c67d1f6099a118668cb8bfb.zip tk-3751f59aa906bc929c67d1f6099a118668cb8bfb.tar.gz tk-3751f59aa906bc929c67d1f6099a118668cb8bfb.tar.bz2 |
Fix potential null dereference flagged by clang static analyzer
Diffstat (limited to 'generic/tkWindow.c')
-rw-r--r-- | generic/tkWindow.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 5e4fabb..09d2f2b 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWindow.c,v 1.99 2008/11/08 18:44:40 dkf Exp $ + * RCS: @(#) $Id: tkWindow.c,v 1.100 2008/12/07 16:34:55 das Exp $ */ #include "tkInt.h" @@ -1019,27 +1019,27 @@ Tk_CreateWindow( * window. */ { TkWindow *parentPtr = (TkWindow *) parent; - TkWindow *winPtr; - if ((parentPtr != NULL) && (parentPtr->flags & TK_ALREADY_DEAD)) { - Tcl_AppendResult(interp, - "can't create window: parent has been destroyed", NULL); - return NULL; - } else if ((parentPtr != NULL) && - (parentPtr->flags & TK_CONTAINER)) { - Tcl_AppendResult(interp, - "can't create window: its parent has -container = yes", NULL); - return NULL; - } - - if (screenName == NULL) { - winPtr = TkAllocWindow(parentPtr->dispPtr, parentPtr->screenNum, - parentPtr); - if (NameWindow(interp, winPtr, parentPtr, name) != TCL_OK) { - Tk_DestroyWindow((Tk_Window) winPtr); + if (parentPtr) { + if (parentPtr->flags & TK_ALREADY_DEAD) { + Tcl_AppendResult(interp, + "can't create window: parent has been destroyed", NULL); return NULL; + } else if (parentPtr->flags & TK_CONTAINER) { + Tcl_AppendResult(interp, + "can't create window: its parent has -container = yes", + NULL); + return NULL; + } else if (screenName == NULL) { + TkWindow *winPtr = TkAllocWindow(parentPtr->dispPtr, + parentPtr->screenNum, parentPtr); + + if (NameWindow(interp, winPtr, parentPtr, name) != TCL_OK) { + Tk_DestroyWindow((Tk_Window) winPtr); + return NULL; + } + return (Tk_Window) winPtr; } - return (Tk_Window) winPtr; } return CreateTopLevelWindow(interp, parent, name, screenName, /* flags */ 0); @@ -1081,32 +1081,32 @@ Tk_CreateAnonymousWindow( * window. */ { TkWindow *parentPtr = (TkWindow *) parent; - TkWindow *winPtr; - - if ((parentPtr != NULL) && (parentPtr->flags & TK_ALREADY_DEAD)) { - Tcl_AppendResult(interp, - "can't create window: parent has been destroyed", NULL); - return NULL; - } else if ((parentPtr != NULL) && - (parentPtr->flags & TK_CONTAINER)) { - Tcl_AppendResult(interp, - "can't create window: its parent has -container = yes", NULL); - return NULL; - } - if (screenName == NULL) { - winPtr = TkAllocWindow(parentPtr->dispPtr, parentPtr->screenNum, - parentPtr); - /* - * Add the anonymous window flag now, so that NameWindow will behave - * correctly. - */ - winPtr->flags |= TK_ANONYMOUS_WINDOW; - if (NameWindow(interp, winPtr, parentPtr, NULL) != TCL_OK) { - Tk_DestroyWindow((Tk_Window) winPtr); + if (parentPtr) { + if (parentPtr->flags & TK_ALREADY_DEAD) { + Tcl_AppendResult(interp, + "can't create window: parent has been destroyed", NULL); return NULL; + } else if (parentPtr->flags & TK_CONTAINER) { + Tcl_AppendResult(interp, + "can't create window: its parent has -container = yes", + NULL); + return NULL; + } else if (screenName == NULL) { + TkWindow *winPtr = TkAllocWindow(parentPtr->dispPtr, + parentPtr->screenNum, parentPtr); + /* + * Add the anonymous window flag now, so that NameWindow will + * behave correctly. + */ + + winPtr->flags |= TK_ANONYMOUS_WINDOW; + if (NameWindow(interp, winPtr, parentPtr, NULL) != TCL_OK) { + Tk_DestroyWindow((Tk_Window) winPtr); + return NULL; + } + return (Tk_Window) winPtr; } - return (Tk_Window) winPtr; } return CreateTopLevelWindow(interp, parent, NULL, screenName, TK_ANONYMOUS_WINDOW); |