cosmo0920 / win32-api

A different, better variant of the Win32API Ruby library
61 stars 10 forks source link

Fix for failing to zero-initialize Win32API structure. #7

Closed peterhuene closed 10 years ago

peterhuene commented 10 years ago

If api_init raises before assigning to the library member, api_free will attempt to FreeLibrary an uninitialized value. This will result in undefined behavior (an access violation, more often than not). With a debugger attached to ruby.exe, it's easy to reproduce with: Win32::API.new('foo', 'V', 'V', 'foo'), without a foo.dll on the load path, and waiting for the API object to be collected.

djberg96 commented 10 years ago

Nice catch, thanks!