[Bug 8511] DragQueryFile returns wrong string length

Wine Bugs wine-bugs at winehq.org
Sun May 27 09:44:09 CDT 2007


http://bugs.winehq.org/show_bug.cgi?id=8511





------- Additional Comments From hadrien-wine at psydk.org  2007-27-05 09:44 -------
>Thanks!  (And if you're at all in the mood, do consider
>submitting a patch to fix this.)

You're welcome ^^ Unfortunately I don't have any Linux box in order to compile
my custom Wine version, and I would like to avoid blind coding without testing.

>BTW what's the symptom in your app, i.e. how does this cause failure?
>And is your app publically available?

The application is called PngOptimizer and can be found here :
http://psydk.org/PngOptimizer

The symptom : when you drop files on the main window, nothing happens.

Here is the explanation :

PngOptimizer filters files by their extension. If you drop many files it will
only keep those that end with "png", "gif", "bmp" and "tga".

In Wine, the file name I get is one more character than the expected length, for
example : "abc.png#" instead of "abc.png" with # being zero.

When I extract the extension from the file name, I get "png#".

When I compare the extracted extension with an acceptable extension, for example
"png", the test fails, as "png#" is not equal to "png".

It can silently work on many applications that use zero-terminated strings as we
usually do in C or C++. For example, strcmp would succeed for "png#" and "png".

But I use my own string class, that manages strings as a character buffer and a
length. Thus, the code point U+0000 is a regular character for me, and the
comparison function I use relies on the length provided by the string object.

When creating the file name string object, its length is initialized with the
length provided by DragQueryFileW.

If you want to see the details, I provide the source code on my website. Check
the MainWnd.cpp file and the function : String MainWnd::GetDraggedFileName(HDROP
hDrop, int nFile)


-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the wine-bugs mailing list