summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2007-10-23 09:23:52 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2007-10-23 09:23:52 (GMT)
commit4de969ee15c8df8c69b978f746350ac026f6622d (patch)
treeddde12aa0e4ed1d49e5f1c3d0b21f5f73be78782
parentb2d705acb529b87d2474d7c8c2c708687bbdd1cd (diff)
downloadtk-4de969ee15c8df8c69b978f746350ac026f6622d.zip
tk-4de969ee15c8df8c69b978f746350ac026f6622d.tar.gz
tk-4de969ee15c8df8c69b978f746350ac026f6622d.tar.bz2
Fixed leak in CreateNamedFont spotted by das.
-rw-r--r--ChangeLog4
-rw-r--r--win/tkWinFont.c18
2 files changed, 10 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index d166935..8d19c1c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-10-23 Pat Thoyts <patthoyts@users.sourceforge.net>
+
+ * win/tkWinFont.c: Fixed leak in CreateNamedFont spotted by das.
+
2007-10-23 Daniel Steffen <das@users.sourceforge.net>
* library/demos/combo.tcl: Aqua GOOBE.
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index 69ae9f9..89b98a7 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.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: tkWinFont.c,v 1.33 2007/09/08 16:13:45 dkf Exp $
+ * RCS: @(#) $Id: tkWinFont.c,v 1.34 2007/10/23 09:23:54 patthoyts Exp $
*/
#include "tkWinInt.h"
@@ -368,19 +368,13 @@ CreateNamedSystemFont(
CONST char* name,
HFONT hFont)
{
- TkFontAttributes *faPtr;
- WinFont *fontPtr;
+ WinFont winfont;
int r;
- TkDeleteNamedFont(interp, tkwin, name);
-
- fontPtr = (WinFont *) ckalloc(sizeof(WinFont));
- InitFont(tkwin, hFont, 0, fontPtr);
- faPtr = (TkFontAttributes*)ckalloc(sizeof(TkFontAttributes));
- memcpy(faPtr, &fontPtr->font.fa, sizeof(TkFontAttributes));
- r = TkCreateNamedFont(interp, tkwin, name, faPtr);
- TkpDeleteFont((TkFont *)fontPtr);
- ckfree((char *) fontPtr);
+ TkDeleteNamedFont(NULL, tkwin, name);
+ InitFont(tkwin, hFont, 0, &winfont);
+ r = TkCreateNamedFont(interp, tkwin, name, &winfont.font.fa);
+ TkpDeleteFont((TkFont *)&winfont);
return r;
}