[v2 02/10] msvcirt: Implement ostream constructors/destructors
Piotr Caban
piotr.caban at gmail.com
Tue Jun 14 13:59:14 CDT 2016
On 06/14/16 19:01, Iván Matellanes wrote:
> On 14/06/16 16:20, Piotr Caban wrote:
>> On 06/14/16 16:40, Iván Matellanes wrote:
>>> /* ??_Dostream@@QAEXXZ */
>>> @@ -2287,23 +2341,48 @@ ostream* __thiscall ostream_assign(ostream
>>> *this, const ostream *rhs)
>>> DEFINE_THISCALL_WRAPPER(ostream_vbase_dtor, 4)
>>> void __thiscall ostream_vbase_dtor(ostream *this)
>>> {
>>> - FIXME("(%p) stub\n", this);
>>> + ios *base = ostream_to_ios(this);
>>> +
>>> + TRACE("(%p)\n", this);
>>> +
>>> + ostream_dtor(base);
>>> + ios_dtor(base);
>>> }
>> The base should be computed using ostream_get_ios while calling ios_dtor:
>> TRACE("(%p)\n", this);
>> ostream_dtor(ostream_to_ios(this));
>> ios_dtor(ostream_get_ios(this));
> Do you mind explaining why is that required? I can't see the reason
ostream_vbase_dtor can be used to destroy object that has virtual base
in any position pointer by vbtable. ostream_get_ios computes it using
object's vbtable. You can easily see it by overwriting ostream->vbtable
with garbage, the application will crash then on Windows.
On the other hand ostream_dtor is a virtual function that assumes "this"
is at fixed offset from "base" that is passed to it. It's done this way
because it has no access to vbtable. It's why you need to use
ostream_to_ios in this case. There's no real need to call ostream_dtor
here because it's an empty function (I don't know if it should be called
here or if ostream_vbase_dtor should only destroy the vbase).
Thanks,
Piotr
More information about the wine-devel
mailing list