Tcl Source Code

View Ticket
Login
Ticket UUID: d052d2a1b01ba2c8f89397810d7e03c01da08ff1
Title: avoid leak in TestsetbytearraylengthObjCmd()
Type: Patch Created on: 2022-08-20 14:21:34
Submitter: chrstphrchvz Assigned to: jan.nijtmans
Subsystem: 12. ByteArray Object Severity: Cosmetic
Priority: 5 Medium Last modified: 2022-08-23 07:06:19
Status: Closed Closed by: jan.nijtmans
Resolution: Fixed Closed on: 2022-08-23 07:06:19
Version: trunk
Description:

If TestsetbytearraylengthObjCmd() is called with a shared value and Tcl_SetByteArrayLength() returns NULL, then the duplicated value returned by Tcl_DuplicateObj() should be freed, otherwise it will be leaked:

--- generic/tclTest.c.orig
+++ generic/tclTest.c
@@ -5130,6 +5130,9 @@
 	obj = objv[1];
     }
     if (NULL == Tcl_SetByteArrayLength(obj, n)) {
+	if (Tcl_IsShared(objv[1])) {

  • Tcl_DecrRefCount(obj);
  • } Tcl_SetResult(interp, "expected bytes", TCL_STATIC); return TCL_ERROR; }
User Comments:
jan.nijtmans added on 2022-08-23 07:06:16:

Fixed [28c98255909b5e7c|here]


jan.nijtmans added on 2022-08-23 07:06:19:

Fixed [28c98255909b5e7c|here]