summaryrefslogtreecommitdiffstats
path: root/generic/tclAlloc.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2009-09-29 04:43:58 (GMT)
committerdgp <dgp@users.sourceforge.net>2009-09-29 04:43:58 (GMT)
commitb9897ce16434d1bf0d8b0053a21c36a8e9519249 (patch)
treecfb2df62951bf644dae366c44a8ebfca3ca41cb2 /generic/tclAlloc.c
parentbbd0122bc4565618ed5632c44bfe8f28aac6475f (diff)
downloadtcl-b9897ce16434d1bf0d8b0053a21c36a8e9519249.zip
tcl-b9897ce16434d1bf0d8b0053a21c36a8e9519249.tar.gz
tcl-b9897ce16434d1bf0d8b0053a21c36a8e9519249.tar.bz2
* generic/tclAlloc.c: Cleaned up various routines in the
* generic/tclCkalloc.c: call stacks for memory allocation to * generic/tclInt.h: guarantee that any size values computed * generic/tclThreadAlloc.c: are within the domains of the routines they get passed to. [Bugs 2557696 and 2557796].
Diffstat (limited to 'generic/tclAlloc.c')
-rw-r--r--generic/tclAlloc.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/generic/tclAlloc.c b/generic/tclAlloc.c
index de21c7c..3df29d7 100644
--- a/generic/tclAlloc.c
+++ b/generic/tclAlloc.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclAlloc.c,v 1.27 2007/12/17 15:28:27 msofer Exp $
+ * RCS: @(#) $Id: tclAlloc.c,v 1.27.2.1 2009/09/29 04:43:58 dgp Exp $
*/
/*
@@ -265,7 +265,7 @@ TclpAlloc(
register union overhead *overPtr;
register long bucket;
register unsigned amount;
- struct block *bigBlockPtr;
+ struct block *bigBlockPtr = NULL;
if (!allocInit) {
/*
@@ -281,9 +281,11 @@ TclpAlloc(
* First the simple case: we simple allocate big blocks directly.
*/
- if (numBytes + OVERHEAD >= MAXMALLOC) {
- bigBlockPtr = (struct block *) TclpSysAlloc((unsigned)
- (sizeof(struct block) + OVERHEAD + numBytes), 0);
+ if (numBytes >= MAXMALLOC - OVERHEAD) {
+ if (numBytes <= UINT_MAX - OVERHEAD -sizeof(struct block)) {
+ bigBlockPtr = (struct block *) TclpSysAlloc((unsigned)
+ (sizeof(struct block) + OVERHEAD + numBytes), 0);
+ }
if (bigBlockPtr == NULL) {
Tcl_MutexUnlock(allocMutexPtr);
return NULL;