[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    Re: odbccp32: Implement SQLGetPrivateProfileString (try 6 - resend)
From:       Nikolay Sivov <bunglehead () gmail ! com>
Date:       2015-06-30 16:06:31
Message-ID: 5592BE87.6000709 () gmail ! com
[Download RAW message or body]

> +    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.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic