summaryrefslogtreecommitdiffstats
path: root/generic/tkTextTag.c
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2003-12-09 13:43:35 (GMT)
committervincentdarley <vincentdarley>2003-12-09 13:43:35 (GMT)
commit67494e4c6046e688baae890e7c3e710f10a0f95e (patch)
tree9fc881a13f58d4f16310b793f1f27fe664b2d764 /generic/tkTextTag.c
parent1485ba3f47705e8f8161ccf7ad9bc55f90814eec (diff)
downloadtk-67494e4c6046e688baae890e7c3e710f10a0f95e.zip
tk-67494e4c6046e688baae890e7c3e710f10a0f95e.tar.gz
tk-67494e4c6046e688baae890e7c3e710f10a0f95e.tar.bz2
fix to memory leaks and reading of freed memory
Diffstat (limited to 'generic/tkTextTag.c')
-rw-r--r--generic/tkTextTag.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c
index 3762de9..4fb536a 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.15 2003/12/05 17:19:06 vincentdarley Exp $
+ * RCS: @(#) $Id: tkTextTag.c,v 1.16 2003/12/09 13:43:35 vincentdarley Exp $
*/
#include "default.h"
@@ -990,6 +990,8 @@ TkTextFreeTag(textPtr, tagPtr)
TkText *textPtr; /* Info about overall widget. */
register TkTextTag *tagPtr; /* Tag being deleted. */
{
+ int i;
+
/* Let Tk do most of the hard work for us */
Tk_FreeConfigOptions((char *) tagPtr, tagPtr->optionTable,
textPtr->tkwin);
@@ -997,6 +999,18 @@ TkTextFreeTag(textPtr, tagPtr)
if (tagPtr->tabArrayPtr != NULL) {
ckfree((char *) tagPtr->tabArrayPtr);
}
+ /* Make sure this tag isn't referenced from the 'current' tag array */
+ for (i = 0; i < textPtr->numCurTags; i++) {
+ if (textPtr->curTagArrayPtr[i] == tagPtr) {
+ for (; i < textPtr->numCurTags-1; i++) {
+ textPtr->curTagArrayPtr[i] = textPtr->curTagArrayPtr[i+1];
+ }
+ textPtr->curTagArrayPtr[textPtr->numCurTags] = NULL;
+ textPtr->numCurTags--;
+ break;
+ }
+ }
+ /* Finally free the tag's memory */
ckfree((char *) tagPtr);
}