diff options
author | das <das@noemail.net> | 2009-09-07 07:29:02 (GMT) |
---|---|---|
committer | das <das@noemail.net> | 2009-09-07 07:29:02 (GMT) |
commit | bb3b7050000ac6157afb32175561f9e19dae3e6e (patch) | |
tree | 482f0c745521d3a4c67098b23132148476c35fbc | |
parent | fc720f1aa979985aeeec0c11ff38da35b42aa9b8 (diff) | |
download | tk-bb3b7050000ac6157afb32175561f9e19dae3e6e.zip tk-bb3b7050000ac6157afb32175561f9e19dae3e6e.tar.gz tk-bb3b7050000ac6157afb32175561f9e19dae3e6e.tar.bz2 |
* generic/tkFocus.c: fix potential null dereference flagged by clang
* generic/tkMenu.c: static analyzer.
* generic/tkTextBTree.c:
* generic/tkTextDisp.c:
* generic/tkTextIndex.c:
* generic/tkConsole.c: silence false positives from clang static
* generic/tkTest.c: analyzer about potential null dereference.
* generic/tkText.c:
* generic/tkTextBTree.c:
* generic/tkTextTag.c:
* generic/tkVisual.c:
FossilOrigin-Name: 7f80c75ac73843fc471ab547b2ee8469e5b61323
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | generic/tkConsole.c | 6 | ||||
-rw-r--r-- | generic/tkFocus.c | 4 | ||||
-rw-r--r-- | generic/tkMenu.c | 4 | ||||
-rw-r--r-- | generic/tkTest.c | 3 | ||||
-rw-r--r-- | generic/tkText.c | 3 | ||||
-rw-r--r-- | generic/tkTextBTree.c | 20 | ||||
-rw-r--r-- | generic/tkTextDisp.c | 6 | ||||
-rw-r--r-- | generic/tkTextIndex.c | 6 | ||||
-rw-r--r-- | generic/tkTextTag.c | 3 | ||||
-rw-r--r-- | generic/tkVisual.c | 3 |
11 files changed, 55 insertions, 18 deletions
@@ -1,3 +1,18 @@ +2009-09-07 Daniel Steffen <das@users.sourceforge.net> + + * generic/tkFocus.c: fix potential null dereference flagged by clang + * generic/tkMenu.c: static analyzer. + * generic/tkTextBTree.c: + * generic/tkTextDisp.c: + * generic/tkTextIndex.c: + + * generic/tkConsole.c: silence false positives from clang static + * generic/tkTest.c: analyzer about potential null dereference. + * generic/tkText.c: + * generic/tkTextBTree.c: + * generic/tkTextTag.c: + * generic/tkVisual.c: + 2009-09-04 Donal K. Fellows <dkf@users.sf.net> * generic/tkInt.h (TkDisplay): Remove fields that are never read from. diff --git a/generic/tkConsole.c b/generic/tkConsole.c index a6825ea..79f16f0 100644 --- a/generic/tkConsole.c +++ b/generic/tkConsole.c @@ -10,10 +10,10 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkConsole.c,v 1.38 2008/10/17 23:18:37 nijtmans Exp $ + * RCS: @(#) $Id: tkConsole.c,v 1.39 2009/09/07 07:29:03 das Exp $ */ -#include "tk.h" +#include "tkInt.h" /* * Each console is associated with an instance of the ConsoleInfo struct. @@ -720,6 +720,8 @@ ConsoleObjCmd( Tcl_ListObjAppendElement(NULL, cmd, objv[2]); } break; + default: + CLANG_ASSERT(0); } Tcl_IncrRefCount(cmd); diff --git a/generic/tkFocus.c b/generic/tkFocus.c index 1c8a682..622867c 100644 --- a/generic/tkFocus.c +++ b/generic/tkFocus.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkFocus.c,v 1.22 2009/07/22 05:35:38 dkf Exp $ + * RCS: @(#) $Id: tkFocus.c,v 1.23 2009/09/07 07:29:03 das Exp $ */ #include "tkInt.h" @@ -1177,7 +1177,7 @@ TkFocusJoin( tmpPtr = winPtr->mainPtr->tlFocusPtr; winPtr->mainPtr->tlFocusPtr = tmpPtr->nextPtr; ckfree((char *)tmpPtr); - } else { + } else if (winPtr && winPtr->mainPtr) { for (tlFocusPtr = winPtr->mainPtr->tlFocusPtr; tlFocusPtr != NULL; tlFocusPtr = tlFocusPtr->nextPtr) { if (tlFocusPtr->nextPtr && diff --git a/generic/tkMenu.c b/generic/tkMenu.c index ac90f0a..d46f622 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMenu.c,v 1.51 2009/04/10 16:16:02 das Exp $ + * RCS: @(#) $Id: tkMenu.c,v 1.52 2009/09/07 07:29:04 das Exp $ */ /* @@ -2060,7 +2060,7 @@ ConfigureMenuCloneEntries( } if (cascadeEntryChanged && (mePtr->namePtr != NULL)) { - if (cascadeMenuRefPtr->menuPtr != NULL) { + if (cascadeMenuRefPtr && cascadeMenuRefPtr->menuPtr != NULL) { Tcl_Obj *newObjv[2]; Tcl_Obj *newCloneNamePtr; Tcl_Obj *pathNamePtr = Tcl_NewStringObj( diff --git a/generic/tkTest.c b/generic/tkTest.c index b7a27a6..22879ee 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkTest.c,v 1.41 2008/11/12 00:15:26 nijtmans Exp $ + * RCS: @(#) $Id: tkTest.c,v 1.42 2009/09/07 07:29:04 das Exp $ */ #include "tkInt.h" @@ -2125,6 +2125,7 @@ CustomOptionSet( if (value == NULL) { objEmpty = 1; + CLANG_ASSERT(value); } else if ((*value)->bytes != NULL) { objEmpty = ((*value)->length == 0); } else { diff --git a/generic/tkText.c b/generic/tkText.c index 7a5fa46..46c2e19 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkText.c,v 1.90 2009/08/09 21:20:33 nijtmans Exp $ + * RCS: @(#) $Id: tkText.c,v 1.91 2009/09/07 07:29:04 das Exp $ */ #include "default.h" @@ -5562,6 +5562,7 @@ SearchCore( int maxExtraLines = 0; const char *startOfLine = Tcl_GetString(theLine); + CLANG_ASSERT(pattern); do { Tcl_UniChar ch; const char *p; diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c index 381f72c..3d2efac 100644 --- a/generic/tkTextBTree.c +++ b/generic/tkTextBTree.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: tkTextBTree.c,v 1.29 2009/04/10 15:53:24 das Exp $ + * RCS: @(#) $Id: tkTextBTree.c,v 1.30 2009/09/07 07:29:04 das Exp $ */ #include "tkInt.h" @@ -1233,8 +1233,9 @@ SplitSeg( /* * Reached end of the text. */ + } else { + segPtr = linePtr->segPtr; } - segPtr = linePtr->segPtr; } } Tcl_Panic("SplitSeg reached end of line!"); @@ -1389,6 +1390,7 @@ TkBTreeDeleteIndexRange( } } changeToLineCount++; + CLANG_ASSERT(curNodePtr); curNodePtr->numChildren--; /* @@ -2465,7 +2467,7 @@ FindTagStart( * level 0 node. */ - while (nodePtr->level > 0) { + while (nodePtr && nodePtr->level > 0) { for (nodePtr = nodePtr->children.nodePtr ; nodePtr != NULL; nodePtr = nodePtr->nextPtr) { for (summaryPtr = nodePtr->summaryPtr ; summaryPtr != NULL; @@ -2479,6 +2481,10 @@ FindTagStart( continue; } + if (nodePtr == NULL) { + return NULL; + } + /* * Work through the lines attached to the level-0 node. */ @@ -2546,7 +2552,7 @@ FindTagEnd( * level 0 node. */ - while (nodePtr->level > 0) { + while (nodePtr && nodePtr->level > 0) { for (lastNodePtr = NULL, nodePtr = nodePtr->children.nodePtr ; nodePtr != NULL; nodePtr = nodePtr->nextPtr) { for (summaryPtr = nodePtr->summaryPtr ; summaryPtr != NULL; @@ -2560,6 +2566,10 @@ FindTagEnd( nodePtr = lastNodePtr; } + if (nodePtr == NULL) { + return NULL; + } + /* * Work through the lines attached to the level-0 node. */ @@ -4277,9 +4287,11 @@ Rebalance( */ if (nodePtr->level == 0) { + CLANG_ASSERT(halfwayLinePtr); otherPtr->children.linePtr = halfwayLinePtr->nextPtr; halfwayLinePtr->nextPtr = NULL; } else { + CLANG_ASSERT(halfwayNodePtr); otherPtr->children.nodePtr = halfwayNodePtr->nextPtr; halfwayNodePtr->nextPtr = NULL; } diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 721647d..9a6b819 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkTextDisp.c,v 1.74 2009/08/04 21:19:27 dkf Exp $ + * RCS: @(#) $Id: tkTextDisp.c,v 1.75 2009/09/07 07:29:04 das Exp $ */ #include "tkInt.h" @@ -8360,7 +8360,9 @@ FreeBaseChunk( ciPtr->chars = NULL; } - Tcl_DStringFree(&((BaseCharInfo *) baseChunkPtr->clientData)->baseChars); + if (baseChunkPtr) { + Tcl_DStringFree(&((BaseCharInfo *) baseChunkPtr->clientData)->baseChars); + } } /* diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index 05459cd..46a2692 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkTextIndex.c,v 1.35 2009/02/06 08:12:07 das Exp $ + * RCS: @(#) $Id: tkTextIndex.c,v 1.36 2009/09/07 07:29:04 das Exp $ */ #include "default.h" @@ -832,7 +832,9 @@ GetIndex( if (tagPtr == textPtr->selTagPtr) { tagName = "sel"; } else { - tagName = Tcl_GetHashKey(&sharedPtr->tagTable, hPtr); + if (hPtr != NULL) { + tagName = Tcl_GetHashKey(&sharedPtr->tagTable, hPtr); + } } Tcl_ResetResult(interp); Tcl_AppendResult(interp, diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index cb13ae1..93a7a55 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.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: tkTextTag.c,v 1.31 2009/02/03 23:55:47 nijtmans Exp $ + * RCS: @(#) $Id: tkTextTag.c,v 1.32 2009/09/07 07:29:04 das Exp $ */ #include "default.h" @@ -1013,6 +1013,7 @@ TkTextCreateTag( tagPtr->textPtr = textPtr; textPtr->refCount++; } else { + CLANG_ASSERT(hPtr); Tcl_SetHashValue(hPtr, tagPtr); } tagPtr->optionTable = diff --git a/generic/tkVisual.c b/generic/tkVisual.c index c2a9622..8665636 100644 --- a/generic/tkVisual.c +++ b/generic/tkVisual.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: tkVisual.c,v 1.12 2008/10/28 22:33:06 nijtmans Exp $ + * RCS: @(#) $Id: tkVisual.c,v 1.13 2009/09/07 07:29:04 das Exp $ */ #include "tkInt.h" @@ -303,6 +303,7 @@ Tk_GetVisual( bestPtr = &visInfoList[i]; bestPrio = prio; } + CLANG_ASSERT(bestPtr); *depthPtr = bestPtr->depth; visual = bestPtr->visual; XFree((char *) visInfoList); |