<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>&nbsp;</DIV>
<DIV dir=ltr>The third version I sent out (yes I know, I was quite sleepy) _is_ correct though.</DIV>
<DIV dir=ltr>&nbsp;</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,&nbsp;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 &lt;mk144210@bcm.edu&gt; wrote:<BR>&gt; This is necessary (bug not sufficient, see my comment in the bug report that I am about<BR>&gt; to post) to fix bug 8678.<BR>&gt;<BR>&gt; It is also clearly correct, as checking the type "returned" by RegQueryValueEx when it fails<BR>&gt; makes no sense.<BR>&gt;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp; size = 0;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp; res = RegQueryValueExW(env, var, NULL, &amp;type, NULL, &amp;size);<BR><BR>-&nbsp;&nbsp;&nbsp; if ((res != ERROR_MORE_DATA &amp;&amp; res != ERROR_FILE_NOT_FOUND) ||<BR>type != REG_SZ)<BR><BR>+&nbsp;&nbsp;&nbsp; if ((res != ERROR_MORE_DATA &amp;&amp; res != ERROR_FILE_NOT_FOUND) ||<BR><BR>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (res == ERROR_SUCCESS &amp;&amp; type != REG_SZ))<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp; {<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RegCloseKey(env);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return res;<BR><BR>This is wrong.&nbsp; 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.&nbsp; 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>