[Win32utils-devel] win32-api, unsigned long vs long in api_call
djberg96 at gmail.com
Wed Aug 19 11:07:03 EDT 2009
On Sun, Aug 16, 2009 at 2:14 PM, Daniel Berger<djberg96 at gmail.com> wrote:
> I noticed this bug:
> Windows XP Pro
> Ruby 1.8.6-p383 built with VC++ 9
> win32-api 1.4.3
> irb(main):001:0> require 'win32/api'
> => true
> irb(main):002:0> GetFileAttributes =
> Win32::API.new('GetFileAttributes', 'S', 'L')
> => #<Win32::API:0x2db8880>
> irb(main):003:0> GetFileAttributes.call("C:/aaabbbcccxxx") # bogus
> file, should return -1
> => 4294967295
> I looked at win32-api.c, line 743, and I saw that, in the api_call
> function, we've declared the return_value variable an unsigned long. I
> changed it to a signed long as well as switching a ULONG2NUM call to
> LONG2NUM and that fixed it.
> I'm kinda shocked I didn't see this until now. Is there any reason for
> me not to apply this change immediately? I'm trying to remember why I
> made it unsigned to begin with.
I've gone ahead and changed it for 1.4.4. If it turns out to be a
critical mistake I'll undo it.
More information about the win32utils-devel