[#81492] [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — normalperson@...

Issue #13618 has been reported by normalperson (Eric Wong).

12 messages 2017/06/01

[ruby-core:81669] Re: [ruby-cvs:66251] ko1:r59074 (trunk): fix to free unallocated memory.

From: SASADA Koichi <ko1@...>
Date: 2017-06-13 23:36:04 UTC
List: ruby-core #81669
Your point is half true.

The problem compiler says using uninitialized variable, like that:

  void *ptr;
  free(ptr);

So my change was:

  void *ptr = NULL;
  if (ptr) free(ptr);

But yes, we only need to:

  void *ptr = NULL;
  free(ptr);

as your point.


On 2017/06/14 7:29, Eric Wong wrote:
> ko1@ruby-lang.org wrote:
>>   New Revision: 59074
>>
>>   https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59074
>>
>>   Log:
>>     fix to free unallocated memory.
>>     
>>     * compile.c (iseq_set_sequence): initialize with NULL for line_info_table
>>       and generated_iseq and check NULL at BADINSN_ERROR.
> 
> I don't think the change to BADINSN_ERROR is necessary.
> 
> xfree (and free) already allow NULL arg; and optimizing away a
> a function call with extra branch isn't worth it for error handling.
> 
> Thanks.
> 
>>
>>   Modified files:
>>     trunk/compile.c


-- 
// SASADA Koichi at atdot dot net

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

In This Thread

Prev Next