summaryrefslogtreecommitdiffstats
path: root/generic/tclStringObj.c
diff options
context:
space:
mode:
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 73aec31..81a4765 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.32.2.3 2009/01/08 17:57:32 dgp Exp $ */
+ * RCS: @(#) $Id: tclStringObj.c,v 1.32.2.4 2009/01/09 15:15:50 dgp Exp $ */
#include "tclInt.h"
@@ -106,9 +106,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) \