summaryrefslogtreecommitdiffstats
path: root/win/tkWinFont.c
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 /win/tkWinFont.c
parentb2d705acb529b87d2474d7c8c2c708687bbdd1cd (diff)
downloadtk-4de969ee15c8df8c69b978f746350ac026f6622d.zip
tk-4de969ee15c8df8c69b978f746350ac026f6622d.tar.gz
tk-4de969ee15c8df8c69b978f746350ac026f6622d.tar.bz2
Fixed leak in CreateNamedFont spotted by das.
Diffstat (limited to 'win/tkWinFont.c')
-rw-r--r--win/tkWinFont.c18
1 files changed, 6 insertions, 12 deletions
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;
}