Bug #1262: Heap Corruption in DL::Handle
http://redmine.ruby-lang.org/issues/show/1262

Author: Charlie Savage
Status: Open, Priority: Normal
Category: core, Target version: 1.9.1
ruby -v: ruby 1.9.2dev (2009-03-06) [i386-mswin32_90]

The test case below on Window, when running with -RCT1, reveals heap corruption.  The problem is that gettimeofday is defined in the c library on windows, so the function is never found.  That causes handle.c to incorrectly deallocate a buffer which it then writes to.  Patch is attached.

Charlie

--------------------

require 'test_base'
require 'dl/import'

module DL
  module LIBC
    extend Importer
    dlload LIBC_SO

    extern "int gettimeofday(timeval*, timezone*)" rescue nil
  end

  class TestImport < TestBase
    def test_doesnt_matter
      assert(true)
    end
  end
end


----------------------------------------
http://redmine.ruby-lang.org