summaryrefslogtreecommitdiffstats
path: root/generic/tclStringObj.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2009-01-09 15:34:32 (GMT)
committerdgp <dgp@users.sourceforge.net>2009-01-09 15:34:32 (GMT)
commit8b9a703b9cb4b40327681b31f0b3c1c2ed01cea5 (patch)
treee81b6e8e9ac4ea9e492f57911adda291b41104fb /generic/tclStringObj.c
parent86d5b60ce155355dda1770c4fef4fdefea64ebf4 (diff)
downloadtcl-8b9a703b9cb4b40327681b31f0b3c1c2ed01cea5.zip
tcl-8b9a703b9cb4b40327681b31f0b3c1c2ed01cea5.tar.gz
tcl-8b9a703b9cb4b40327681b31f0b3c1c2ed01cea5.tar.bz2
* generic/tclStringObj.c (STRING_SIZE): Corrected failure to limit
memory allocation requests to the sizes that can be supported by Tcl's memory allocation routines. [Bug 2494093].
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r--generic/tclStringObj.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index c834de5..5785d72 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -33,7 +33,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclStringObj.c,v 1.77 2009/01/08 17:58:59 dgp Exp $ */
+ * RCS: @(#) $Id: tclStringObj.c,v 1.78 2009/01/09 15:34:33 dgp Exp $ */
#include "tclInt.h"
#include "tommath.h"
@@ -108,9 +108,12 @@ typedef struct String {
#define STRING_UALLOC(numChars) \
((numChars) * sizeof(Tcl_UniChar))
#define STRING_SIZE(ualloc) \
- ((unsigned) ((ualloc) \
- ? sizeof(String) - sizeof(Tcl_UniChar) + (ualloc) \
- : sizeof(String)))
+ ((unsigned) ((ualloc) \
+ ? ((sizeof(String) - sizeof(Tcl_UniChar) + (ualloc) > INT_MAX) \
+ ? Tcl_Panic("unable to alloc %u bytes", \
+ sizeof(String) - sizeof(Tcl_UniChar) + (ualloc)), INT_MAX \
+ : (sizeof(String) - sizeof(Tcl_UniChar) + (ualloc))) \
+ : sizeof(String)))
#define GET_STRING(objPtr) \
((String *) (objPtr)->internalRep.otherValuePtr)
#define SET_STRING(objPtr, stringPtr) \