<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Dec 16, 2019 at 11:52 AM Dmitry Timoshkov <<a href="mailto:dmitry@baikal.ru">dmitry@baikal.ru</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Nikolay Sivov <<a href="mailto:bunglehead@gmail.com" target="_blank">bunglehead@gmail.com</a>> wrote:<br>
<br>
> > > > +                        hr = IADsOpenDSObject_OpenDSObject(adsopen,<br>
> > (BSTR)path, (BSTR)user, (BSTR)password, reserved, &disp);<br>
> > > > +                        if (hr == S_OK)<br>
> > > You cannot cast to a BSTR, it will corrupt the data structure.<br>
> ><br>
> > I depends wheather the callee uses SysStringLen() and friends, in this<br>
> > particular case it works just fine, there are many other places in the code<br>
> > when it's not necessary to create intermediate copies of the strings.<br>
> ><br>
> <br>
> It does not matter if it works in this case, arguments should use correct<br>
> types. If we have similar violations somewhere else, those need fixing as<br>
> well.<br>
<br>
That's a pretty incorrect assertion, there's nothing wrong in casting<br>
BSTR to LPWSTR and vice versa.<br></blockquote><div><br></div><div>What's incorrect about it? You can use BSTR as WCHAR * argument, obviously. Not the other way around, even if it happens to work.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
-- <br>
Dmitry.<br>
<br>
</blockquote></div></div>