From 3ec1915d9882b60ed59ca41d27b14b6a74ce2e52 Mon Sep 17 00:00:00 2001 From: dkf Date: Wed, 25 Mar 2009 09:06:57 +0000 Subject: Prevent zero-size malloc() calls. [Bug 2178820] FossilOrigin-Name: ddd898d0a3c19c7df5dc1f7651c60623411c506c --- ChangeLog | 4 ++++ generic/ttk/ttkTheme.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f7b27d0..0b895dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-03-25 Donal K. Fellows + * generic/ttk/ttkTheme.c (BuildOptionMap, NewElementClass): + [Bug 2178820]: Ensure that zero-size allocations don't happen; some + malloc implementations don't like it at all. + * win/wish.exe.manifest.in: [Bug 1871101]: Add magic to make Tk not be blurred on Vista with large fonts. diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c index 9787b4b..e19ca20 100644 --- a/generic/ttk/ttkTheme.c +++ b/generic/ttk/ttkTheme.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. * - * $Id: ttkTheme.c,v 1.18 2009/02/08 19:35:35 jenglish Exp $ + * $Id: ttkTheme.c,v 1.19 2009/03/25 09:06:58 dkf Exp $ */ #include @@ -182,7 +182,7 @@ static OptionMap BuildOptionMap(Ttk_ElementClass *elementClass, Tk_OptionTable optionTable) { OptionMap optionMap = (OptionMap)ckalloc( - sizeof(const Tk_OptionSpec) * elementClass->nResources); + sizeof(const Tk_OptionSpec) * elementClass->nResources + 1); int i; for (i = 0; i < elementClass->nResources; ++i) { @@ -241,7 +241,7 @@ NewElementClass(const char *name, Ttk_ElementSpec *specPtr,void *clientData) /* Initialize default values: */ elementClass->defaultValues = (Tcl_Obj**) - ckalloc(elementClass->nResources * sizeof(Tcl_Obj *)); + ckalloc(elementClass->nResources * sizeof(Tcl_Obj *) + 1); for (i=0; i < elementClass->nResources; ++i) { const char *defaultValue = specPtr->options[i].defaultValue; if (defaultValue) { -- cgit v0.12