diff options
author | nijtmans <nijtmans> | 2010-12-10 21:59:23 (GMT) |
---|---|---|
committer | nijtmans <nijtmans> | 2010-12-10 21:59:23 (GMT) |
commit | 5a5a4f6082fa872003f5fdeb2fb4a0ebb623cdd0 (patch) | |
tree | f5a596654db0ccc6fc206c51f688b6bd218ce97a /generic/tclCkalloc.c | |
parent | f2f87ec0246421e1760b52b1474c93a231edac92 (diff) | |
download | tcl-5a5a4f6082fa872003f5fdeb2fb4a0ebb623cdd0.zip tcl-5a5a4f6082fa872003f5fdeb2fb4a0ebb623cdd0.tar.gz tcl-5a5a4f6082fa872003f5fdeb2fb4a0ebb623cdd0.tar.bz2 |
[Bug 3129448]: Possible over-allocation on 64-bit platforms, part 2
Diffstat (limited to 'generic/tclCkalloc.c')
-rw-r--r-- | generic/tclCkalloc.c | 8 |
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) { |