msi: Do not use type value if call to RegQueryValueEx failed.

Misha Koshelev mk144210 at bcm.edu
Wed Jun 13 10:23:52 CDT 2007


On Tue, 2007-06-12 at 23:22 -0700, James Hawkins wrote:
> On 6/12/07, Misha Koshelev <mk144210 at bcm.edu> wrote:
> > This is necessary (bug not sufficient, see my comment in the bug report that I am about
> > to post) to fix bug 8678.
> >
> > It is also clearly correct, as checking the type "returned" by RegQueryValueEx when it fails
> > makes no sense.
> >
> 
>      size = 0;
> 
>      res = RegQueryValueExW(env, var, NULL, &type, NULL, &size);
> 
> -    if ((res != ERROR_MORE_DATA && res != ERROR_FILE_NOT_FOUND) ||
> type != REG_SZ)
> 
> +    if ((res != ERROR_MORE_DATA && res != ERROR_FILE_NOT_FOUND) ||
> 
> +        (res == ERROR_SUCCESS && type != REG_SZ))
> 
>      {
> 
>          RegCloseKey(env);
> 
>          return res;
> 
> This is wrong.  If res == ERROR_SUCCESS, then the first condition
> evaluates to TRUE and we fall through to exit, but then again, res
> will never be ERROR_SUCCESS after that particular call.  Either way, I
> have a patch ready to send in that fixes the entire action.
> 

---
http://msdn2.microsoft.com/en-us/library/ms724911.aspx
If lpData is NULL, and lpcbData is non-NULL, the function returns
ERROR_SUCCESS and stores the size of the data, in bytes, in the variable
pointed to by lpcbData. This enables an application to determine the
best way to allocate a buffer for the value's data.
---

Clearly a rewrite is better than changing one line, but I hope your
rewrite checks for ERROR_SUCCESS and not ERROR_MORE_DATA in this case.

Misha



More information about the wine-devel mailing list