Issue #10535 has been updated by Eric Wong.


 asmaloney / gmail.com wrote:
 > IF !defined(HAVE_WORKING_FORK) and !defined(HAVE_SPAWNV), THEN argc
 > and argv are declared. (lines 5938, 5939)
 > Unless I'm missing something in the #if #else #endif fiesta, they
 > don't seem to be initialized anywhere.
 
 I concur. On the other hand, which platforms are affected by this
 problem?  Any platform maintainers care to comment?  Maybe we can
 drop the code :)
 
 A side note: we'd be better off reimplementing pipe_open (and similar
 functions) individually on a per-platform basis to avoid the ugly
 CPP conditionals.
 
 Right now, it's hard-to-read for every platform.  Of course, this split
 requires much coordination between platform maintainers...

----------------------------------------
Bug #10535: Potential uninitialized reference pipe_open() in io.c
https://bugs.ruby-lang.org/issues/10535#change-50054

* Author: Andy Maloney
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.2.0dev (2014-11-22 trunk 48537) [x86_64-darwin12.0]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
(From git commit f5063b7ea7e774519602f7a112d9acf536a1da33 of 22 November 2014.)

In **io.c** in the following function:

~~~
static VALUE
pipe_open(VALUE execarg_obj, const char *modestr, int fmode, convconfig_t *convconfig)

~~~

IF !defined(HAVE_WORKING_FORK) and !defined(HAVE_SPAWNV), THEN argc and argv are declared. (lines 5938, 5939)

Unless I'm missing something in the #if #else #endif fiesta, they don't seem to be initialized anywhere.

Then in the #else case at line 6069, we have this:

~~~
#else
    if (argc) {
	prog = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" "));
	cmd = StringValueCStr(prog);
    }

~~~

Best case, the compiler initializes argc to 0, which means this is dead code.  Worst case, the compiler chooses not to initialize to 0, then *Bad Things* will happen.




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