public inbox for cygwin-developers@cygwin.com
 help / color / mirror / Atom feed
* Potential handle leaks in dup_worker
@ 2021-02-08 17:39 Ken Brown
  2021-02-09  9:47 ` Corinna Vinschen
  0 siblings, 1 reply; 12+ messages in thread
From: Ken Brown @ 2021-02-08 17:39 UTC (permalink / raw)
  To: cygwin-devel

I've had occasion to work through dtable::dup_worker, and I'm seeing the 
potential for leaks of path_conv handles.  I haven't seen any evidence that the 
leaks actually occur, but the code should probably be cleaned up if I'm right.

dup_worker calls clone to create newfh from oldfh.  clone calls copyto, which 
calls operator=, which calls path_conv::operator=, which duplicates the 
path_conv handle from oldfh to newfh.  Then copyto calls reset, which calls 
path_conv::operator<<, which again duplicates the path_conv handle from oldfh to 
newfh without first closing the previous one.  That's the first leak.

Further on, dup_worker calls newfh->pc.reset_conv_handle (), which sets the 
path_conv handle of newfh to NULL without closing the existing handle.  So 
that's a second leak.  This one is easily fixed by calling close_conv_handle 
instead of reset_conv_handle.

As a practical matter, I think the path_conv handle of oldfh is always NULL when 
dup_worker is called, so there's no actual leak.

I may well be confused and/or missing something.

Ken

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-02-10  9:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08 17:39 Potential handle leaks in dup_worker Ken Brown
2021-02-09  9:47 ` Corinna Vinschen
2021-02-09 14:19   ` Ken Brown
2021-02-09 15:02     ` Corinna Vinschen
2021-02-09 15:04       ` Corinna Vinschen
2021-02-09 15:31       ` Ken Brown
2021-02-09 16:12         ` Corinna Vinschen
2021-02-09 17:13           ` Ken Brown
2021-02-09 19:12             ` Ken Brown
2021-02-09 20:52               ` Corinna Vinschen
2021-02-09 22:31                 ` Ken Brown
2021-02-10  9:52                   ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).