Issue #15116 has been updated by jaruga (Jun Aruga).


Thank you for checking my code!

> > Fix leaked handle variable "n" in process.c.
>
> If n is 0..2, dup2 to the same fd does nothing, and n must not be closed.

About above thing,

I compared process.c#rb_daemon with pty.c#chfunc .
Similar implementation, but a little different.

https://github.com/ruby/ruby/blob/trunk/ext/pty/pty.c#L130-L146

In the case of `pty.c`, the "leaked handle" was not detected for the return value of `rb_cloexec_open`. even when `close` function can be executed for for the return value "slave" (= file descriptor) == 0, 1 or 2.

In `process.c`, when the return value n < 0, is it no problem?


----------------------------------------
Bug #15116: Fixing issues detected by an Analysis tool.
https://bugs.ruby-lang.org/issues/15116#change-74069

* Author: jaruga (Jun Aruga)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
When running a code analysis tool including several sub tools (mainly Coverty [1]), some issues were detected by it.
You can refer attached issues_report.txt for detail.

Some issues in the issues_report.txt might be false positive.
(Those might be wrongly detected.)

I tried to fix those by below 2 pull-requests.
https://github.com/ruby/ruby/pull/1956
https://github.com/ruby/net-telnet/pull/15

The summary is
* Fix leaked storage in addr2line.c.
* Fix passing freed pointer as an argument in gc.c.
* Fix leaked handle variable "n" in process.c.
* Fix for "top_root" leaking the resource.

After above patches, the issues were not detected.
But I need your help to check if my code is valid.

Thank you.

[1] https://scan.coverity.com/


---Files--------------------------------
issues_report.txt (7.74 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>