diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclBinary.c | 12 |
1 files changed, 5 insertions, 7 deletions
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; |