<HTML dir=ltr><HEAD><TITLE>Re: msi: Do not use type value if call to RegQueryValueEx failed.</TITLE>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.2900.3086" name=GENERATOR></HEAD>
<BODY>
<DIV id=idOWAReplyText33932 dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2><A href="http://www.winehq.org/pipermail/wine-patches/2007-June/040336.html">http://www.winehq.org/pipermail/wine-patches/2007-June/040336.html</A></FONT></DIV></DIV>
<DIV dir=ltr> </DIV>
<DIV dir=ltr>The third version I sent out (yes I know, I was quite sleepy) _is_ correct though.</DIV>
<DIV dir=ltr> </DIV>
<DIV dir=ltr>And that particular call _will_ return ERROR_SUCCESS and _not_ ERROR_MORE_DATA,</DIV>
<DIV dir=ltr>see:</DIV>
<DIV dir=ltr><A href="http://msdn2.microsoft.com/en-us/library/ms724911.aspx">http://msdn2.microsoft.com/en-us/library/ms724911.aspx</A><BR></DIV>
<DIV dir=ltr>Specifically, a call to RegQueryValueEx with a NULL data pointer and a valid size pointer returns<BR>ERROR_SUCCESS if the size pointer is filled, _not_ ERROR_MORE_DATA, which is returned<BR>if a valid data pointer is passed.<BR></DIV>
<DIV dir=ltr>Misha</DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> James Hawkins [mailto:truiken@gmail.com]<BR><B>Sent:</B> Wed 6/13/2007 1:22 AM<BR><B>To:</B> wine-devel@winehq.org<BR><B>Cc:</B> Koshelev, Misha Vladislavo<BR><B>Subject:</B> Re: msi: Do not use type value if call to RegQueryValueEx failed.<BR></FONT><BR></DIV>
<DIV>
<P><FONT size=2>On 6/12/07, Misha Koshelev <mk144210@bcm.edu> wrote:<BR>> This is necessary (bug not sufficient, see my comment in the bug report that I am about<BR>> to post) to fix bug 8678.<BR>><BR>> It is also clearly correct, as checking the type "returned" by RegQueryValueEx when it fails<BR>> makes no sense.<BR>><BR><BR> size = 0;<BR><BR> res = RegQueryValueExW(env, var, NULL, &type, NULL, &size);<BR><BR>- if ((res != ERROR_MORE_DATA && res != ERROR_FILE_NOT_FOUND) ||<BR>type != REG_SZ)<BR><BR>+ if ((res != ERROR_MORE_DATA && res != ERROR_FILE_NOT_FOUND) ||<BR><BR>+ (res == ERROR_SUCCESS && type != REG_SZ))<BR><BR> {<BR><BR> RegCloseKey(env);<BR><BR> return res;<BR><BR>This is wrong. If res == ERROR_SUCCESS, then the first condition<BR>evaluates to TRUE and we fall through to exit, but then again, res<BR>will never be ERROR_SUCCESS after that particular call. Either way, I<BR>have a patch ready to send in that fixes the entire action.<BR><BR>--<BR>James Hawkins<BR></FONT></P></DIV></BODY></HTML>