summaryrefslogtreecommitdiffstats
path: root/generic/tclCkalloc.c
diff options
context:
space:
mode:
authornijtmans <nijtmans>2010-12-10 21:59:23 (GMT)
committernijtmans <nijtmans>2010-12-10 21:59:23 (GMT)
commit8bfe2a72f81586691fd3ddf6ff8b40b74aeb312d (patch)
treef5a596654db0ccc6fc206c51f688b6bd218ce97a /generic/tclCkalloc.c
parentc62e68e149eae9355fd8af6bd73c7f50b291b9b8 (diff)
downloadtcl-8bfe2a72f81586691fd3ddf6ff8b40b74aeb312d.zip
tcl-8bfe2a72f81586691fd3ddf6ff8b40b74aeb312d.tar.gz
tcl-8bfe2a72f81586691fd3ddf6ff8b40b74aeb312d.tar.bz2
[Bug 3129448]: Possible over-allocation on 64-bit platforms, part 2
Diffstat (limited to 'generic/tclCkalloc.c')
-rw-r--r--generic/tclCkalloc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/generic/tclCkalloc.c b/generic/tclCkalloc.c
index 4314554..414344a 100644
--- a/generic/tclCkalloc.c
+++ b/generic/tclCkalloc.c
@@ -14,7 +14,7 @@
*
* This code contributed by Karl Lehenbauer and Mark Diekhans
*
- * RCS: @(#) $Id: tclCkalloc.c,v 1.42 2010/12/06 09:01:49 nijtmans Exp $
+ * RCS: @(#) $Id: tclCkalloc.c,v 1.43 2010/12/10 21:59:23 nijtmans Exp $
*/
#include "tclInt.h"
@@ -814,6 +814,7 @@ MemoryCmd(
FILE *fileP;
Tcl_DString buffer;
int result;
+ size_t len;
if (argc < 2) {
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
@@ -909,9 +910,10 @@ MemoryCmd(
if ((curTagPtr != NULL) && (curTagPtr->refCount == 0)) {
TclpFree((char *) curTagPtr);
}
- curTagPtr = (MemTag *) TclpAlloc(TAG_SIZE(strlen(argv[2])));
+ len = strlen(argv[2]);
+ curTagPtr = (MemTag *) TclpAlloc(TAG_SIZE(len));
curTagPtr->refCount = 0;
- strcpy(curTagPtr->string, argv[2]);
+ memcpy(curTagPtr->string, argv[2], len + 1);
return TCL_OK;
}
if (strcmp(argv[1],"trace") == 0) {