[Win32utils-devel] win32-api, unsigned long vs long in api_call
djberg96 at gmail.com
Sun Aug 16 16:14:55 EDT 2009
I noticed this bug:
Windows XP Pro
Ruby 1.8.6-p383 built with VC++ 9
irb(main):001:0> require 'win32/api'
irb(main):002:0> GetFileAttributes =
Win32::API.new('GetFileAttributes', 'S', 'L')
irb(main):003:0> GetFileAttributes.call("C:/aaabbbcccxxx") # bogus
file, should return -1
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.
More information about the win32utils-devel