[poppler] [PATCH] Fix GDir's handling of return values from FindFirstFile

Adam Batkin adam at batkin.net
Wed Apr 2 16:45:15 PDT 2008


Hi,

I believe that there is a small bug in GDir's Windows implementation, if 
called on a directory that does not exist and you then try to enumerate 
its entries (getNextEntry()).

Basically GDir was storing the return value of its call to 
FindFirstFile() in GDir::hnd, but using NULL as a sentinel for invalid 
values, but in fact FindFirstFile() returns INVALID_HANDLE_VALUE (-1).

This patch replaces assignments to NULL with assignments to 
INVALID_HANDLE_VALUE and all checks now check against 
INVALID_HANDLE_VALUE instead of NULL.

So if you are ever using poppler on Windows and your app suddenly 
crashes (which I was only able to do by compiling with all the debugging 
options turned on, otherwise I only got funny entries in my log like 
"Error: Couldn't open 'nameToUnicode' file 
'D:\kde-mingw\share\poppler\nameToUnicode\{„žYø!'") this may be why.

You know what would also be nice...(would you be open to a patch?) not 
hardcoding POPPLER_DATADIR, since especially on Windows you never know 
where it will be installed.

I hope this helps (and I hope I did everything properly...),

-Adam Batkin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-handle.diff
Type: text/x-patch
Size: 1114 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/poppler/attachments/20080403/4c6d3bbe/attachment.bin 


More information about the poppler mailing list