[Win32utils-devel] win32-api, unsigned long vs long in api_call

Daniel Berger djberg96 at gmail.com
Sun Aug 16 16:14:55 EDT 2009


Hi,

I noticed this bug:

Windows XP Pro
Ruby 1.8.6-p383 built with VC++ 9
win32-api 1.4.3

C:\>irb
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.

Regards,

Dan


More information about the win32utils-devel mailing list