user32: GetClassName should return the number of chars copied.

Dmitry Timoshkov dmitry at codeweavers.com
Sun Oct 22 03:23:37 CDT 2006


"Mike McCormack" <mike at codeweavers.com> wrote:

> INT WINAPI GetClassNameA( HWND hwnd, LPSTR buffer, INT count )
> {
> -    INT ret = GlobalGetAtomNameA( GetClassLongA( hwnd, GCW_ATOM ), buffer, count );
> +    INT ret;
> +
> +    ret = GlobalGetAtomNameA( GetClassLongA( hwnd, GCW_ATOM ), buffer, count );
> +    if (!ret && count)
> +        ret = lstrlenA( buffer );

This won't work as expected if hwnd is invalid and buffer contains
some '\0' terminated data. Probably a better aproach would be to call
GlobalGetAtomNameA with a buffer of size MAX_ATOM_LEN + 1 allocated
on the stack (MAX_ATOM_LEN is defined in dlls/kernel32/atom.c as 255)
and only if the call succeeds copy the data. GetClassNameW neededs
to be fixed as well.

-- 
Dmitry.



More information about the wine-devel mailing list