odbccp32: Implement SQLGetPrivateProfileString (try 6 - resend)

Nikolay Sivov bunglehead at gmail.com
Tue Jun 30 11:06:31 CDT 2015


> +    sect = heap_strdupAtoW(lpszSection);
> +    entry = heap_strdupAtoW(lpszEntry);
> +    string = heap_strdupAtoW(lpszDefault);
> +    file = heap_strdupAtoW(lpszFilename);
> +    retval = heap_alloc(cbRetBuffer*sizeof(WCHAR));
> +
> +    ret = SQLGetPrivateProfileStringW(sect, entry, string, retval, cbRetBuffer, file);
> +    if(ret)
> +    {
> +        WideCharToMultiByte(CP_ACP, 0, retval, -1, RetBuffer, ret+1, NULL, NULL);
> +    }
> +
> +    heap_free(sect);
> +    heap_free(entry);
> +    heap_free(string);
> +    heap_free(file);
> +
> +    heap_free(retval);

I think it's still the same issue as last time - you're using WCHAR vs 
CHAR buffer lengths wrong, it might work for this function as long as 
it's always called with simple strings. But in general 
WideCharToMultiByte should not be used like that: 'cbRetBuffer' you got 
here is A-buffer length, yet you allocate W-buffer of this length. Later 
when you convert W->A you use return value from W-call as A-buffer length.



More information about the wine-devel mailing list