diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | generic/tclBinary.c | 12 |
2 files changed, 10 insertions, 7 deletions
@@ -1,3 +1,8 @@ +2012-08-23 Jan Nijtmans <nijtmans@users.sf.net> + + * generic/tclBinary.c: [Bug 3496014] Unecessary memset() in + Tcl_SetByteArrayObj(). + 2012-08-20 Don Porter <dgp@users.sourceforge.net> * generic/tclPathObj.c: [Bug 3559678] Fix bad filename normalization diff --git a/generic/tclBinary.c b/generic/tclBinary.c index a1e836e..4953e27 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -303,16 +303,14 @@ Tcl_SetByteArrayObj( TclFreeIntRep(objPtr); Tcl_InvalidateStringRep(objPtr); - length = (length < 0) ? 0 : length; + if (length < 0) { + length = 0; + } byteArrayPtr = ckalloc(BYTEARRAY_SIZE(length)); byteArrayPtr->used = length; byteArrayPtr->allocated = length; - if (length) { - if (bytes) { - memcpy(byteArrayPtr->bytes, bytes, (size_t) length); - } else { - memset(byteArrayPtr->bytes, 0, (size_t) length); - } + if (length && bytes) { + memcpy(byteArrayPtr->bytes, bytes, (size_t) length); } objPtr->typePtr = &tclByteArrayType; |