summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2006-09-24 20:46:40 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2006-09-24 20:46:40 (GMT)
commitee372e0ed9868f69a64753ccad5555936df09fd3 (patch)
treeb7c0d440e13e7bf0d0ef837d01ae35bcecc9f403
parent8d6152095bc898e1db290fe1865eb783c070e3e3 (diff)
downloadtcl-ee372e0ed9868f69a64753ccad5555936df09fd3.zip
tcl-ee372e0ed9868f69a64753ccad5555936df09fd3.tar.gz
tcl-ee372e0ed9868f69a64753ccad5555936df09fd3.tar.bz2
* generic/tclStringObj.c (STRING_SIZE): fix allocation for
0-length strings. This is coverity's bugs #54-5
-rw-r--r--ChangeLog3
-rw-r--r--generic/tclStringObj.c6
2 files changed, 7 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index a4c5a58..98d98ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@
* generic/tclParse.c (Tcl_ParseCommand): also return an error if
start==NULL and numBytes<0. This is coverity's bug #20
+ * generic/tclStringObj.c (STRING_SIZE): fix allocation for
+ 0-length strings. This is coverity's bugs #54-5
+
2006-09-22 Andreas Kupries <andreask@activestate.com>
* generic/tclInt.h: Moved TIP#268's field 'packagePrefer' to the
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 40ec1bf..af94b6d 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.57 2006/08/28 16:05:32 dgp Exp $ */
+ * RCS: @(#) $Id: tclStringObj.c,v 1.58 2006/09/24 20:46:40 msofer Exp $ */
#include "tclInt.h"
#include "tommath.h"
@@ -110,7 +110,9 @@ typedef struct String {
#define STRING_UALLOC(numChars) \
(numChars * sizeof(Tcl_UniChar))
#define STRING_SIZE(ualloc) \
- ((unsigned) (sizeof(String) - sizeof(Tcl_UniChar) + ualloc))
+ ((unsigned) ((ualloc) \
+ ? sizeof(String) - sizeof(Tcl_UniChar) + (ualloc) \
+ : sizeof(String)))
#define GET_STRING(objPtr) \
((String *) (objPtr)->internalRep.otherValuePtr)
#define SET_STRING(objPtr, stringPtr) \