diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-06-02 22:05:03 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-06-02 22:05:03 (GMT) |
commit | 7e152743beb2995911a1a99c808a5e52ede08d6d (patch) | |
tree | 021b1187bc639c7a1f62a07d845ac19d3481254e | |
parent | 0513ad381ad912b55f09bc7a49d00b1429e881ea (diff) | |
download | tcl-7e152743beb2995911a1a99c808a5e52ede08d6d.zip tcl-7e152743beb2995911a1a99c808a5e52ede08d6d.tar.gz tcl-7e152743beb2995911a1a99c808a5e52ede08d6d.tar.bz2 |
In TclAttemptInitStringRep(): Don't do a memcpy if attemptckalloc() fails
-rw-r--r-- | generic/tclInt.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h index d40bbe5..7114d66 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4516,9 +4516,9 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file, TclInitEmptyStringRep(objPtr) \ ) : ( \ (objPtr)->bytes = (char *)attemptckalloc((len) + 1U), \ - memcpy((objPtr)->bytes, (bytePtr) ? (bytePtr) : &tclEmptyString, (len)), \ - (objPtr)->bytes[len] = '\0', \ - (objPtr)->length = (len) \ + (objPtr)->length = ((objPtr)->bytes) ? \ + (memcpy((objPtr)->bytes, (bytePtr) ? (bytePtr) : &tclEmptyString, (len)), \ + (objPtr)->bytes[len] = '\0', (len)) : (-1) \ )), (objPtr)->bytes) /* |