Tcl Source Code

View Ticket
Login
Ticket UUID: 517503
Title: mem leak in Tcl_GetsObjCmd ?
Type: Bug Version: None
Submitter: msofer Created on: 2002-02-14 13:32:06
Subsystem: 24. Channel Commands Assigned To: andreas_kupries
Priority: 8 Severity:
Status: Closed Last Modified: 2002-02-15 02:24:55
Resolution: Fixed Closed By: andreas_kupries
    Closed on: 2002-02-14 19:24:55
Description:
While looking through the sources, I have stumbled
accross something that looks to me like a possible
memory leak. I may be missing something though.

The issue is in function Tcl_GetsObjCmd (tclIOCmd.c):
on line 253 we see
    if (objc == 3) {
Tcl_DecrRefCount(linePtr);
    }
I think that linePtr should be Tcl_DecrRefCount'ed also
when objc is not equal to 3.

As it is, I suspect the linePtr object will be leaked
when there is an error reading the channel in
                  set myVar [gets $chan]
i.e., with (objc == 2)
User Comments: andreas_kupries added on 2002-02-15 02:24:55:
Logged In: YES 
user_id=75003

Committed to head.

msofer added on 2002-02-15 02:19:23:
Logged In: YES 
user_id=148712

Yep, that's it.

andreas_kupries added on 2002-02-15 02:12:00:

File Added - 17880: 517503.diff

andreas_kupries added on 2002-02-15 02:11:59:
Logged In: YES 
user_id=75003

Trivial patch. Please review :)

andreas_kupries added on 2002-02-15 02:05:37:
Logged In: YES 
user_id=75003

I agree.

dkf added on 2002-02-14 21:19:04:
Logged In: YES 
user_id=79902

Looks like a leak to me, though an awkward one to hit in
practice.

Attachments: