Fix for LoadStringW

Dmitry Timoshkov dmitry at codeweavers.com
Mon Jan 21 21:16:54 CST 2008


"Christopher" <raccoonone at procyongames.com> wrote:

> @@ -363,10 +363,14 @@ INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id,
>     WCHAR *p;
>     int string_num;
>     int i;
> +    int strlen;

strlen is not the best variable name.

>     TRACE("instance = %p, id = %04x, buffer = %p, length = %d\n",
>           instance, resource_id, buffer, buflen);
> 
> +    if (buffer == NULL) 
> +        return 0;

Please add a check whether last error value should be set as well. Also this
fix breaks other places in Wine which rely on previous behaviour (I repeat it
the 3rd time already).

> +    /* Copy the resource since it is not '\0' terminated, and add '\0' to the end */
> +    if(resourcepointer != NULL)
> +    {
> +        memcpy(copiedstring, resourcepointer, strlen * sizeof(WCHAR));
> +        copiedstring[strlen] = '\0';
> +    }

Again, if () above is not needed. But ok(resourcepointer != NULL) is (right after
appropriate LoadStringW call).

-- 
Dmitry.



More information about the wine-devel mailing list