summaryrefslogtreecommitdiffstats
path: root/generic/tclAlloc.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2009-09-28 21:20:50 (GMT)
committerdgp <dgp@users.sourceforge.net>2009-09-28 21:20:50 (GMT)
commit7ad9ba94f77eba7345aaf7872f5f40681d7e16a4 (patch)
tree4bbcc35d2c98ef432ee08599ec2bd541b906a6ba /generic/tclAlloc.c
parentcd55adb09ee0d5e492e024cac7a43350933b9dd3 (diff)
downloadtcl-7ad9ba94f77eba7345aaf7872f5f40681d7e16a4.zip
tcl-7ad9ba94f77eba7345aaf7872f5f40681d7e16a4.tar.gz
tcl-7ad9ba94f77eba7345aaf7872f5f40681d7e16a4.tar.bz2
* generic/tclAlloc.c: Cleaned up various routines in the
* generic/tclCkalloc.c: call stacks for memory allocation to * generic/tclParse.c: 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 12c0201..7decf22 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.16.2.3 2007/09/22 15:46:45 das Exp $
+ * RCS: @(#) $Id: tclAlloc.c,v 1.16.2.4 2009/09/28 21:20:50 dgp Exp $
*/
/*
@@ -272,7 +272,7 @@ TclpAlloc(nbytes)
register union overhead *op;
register long bucket;
register unsigned amt;
- struct block *bigBlockPtr;
+ struct block *bigBlockPtr = NULL;
if (!allocInit) {
/*
@@ -286,9 +286,11 @@ TclpAlloc(nbytes)
/*
* First the simple case: we simple allocate big blocks directly
*/
- if (nbytes + OVERHEAD >= MAXMALLOC) {
- bigBlockPtr = (struct block *) TclpSysAlloc((unsigned)
- (sizeof(struct block) + OVERHEAD + nbytes), 0);
+ if (nbytes >= MAXMALLOC - OVERHEAD) {
+ if (nbytes <= UINT_MAX - OVERHEAD - sizeof(struct block)) {
+ bigBlockPtr = (struct block *) TclpSysAlloc((unsigned)
+ (sizeof(struct block) + OVERHEAD + nbytes), 0);
+ }
if (bigBlockPtr == NULL) {
Tcl_MutexUnlock(allocMutexPtr);
return NULL;