[vlc-devel] [PATCH] npapi: zero NPClass before using.

Sergey Radionov rsatom at gmail.com
Thu Dec 1 07:20:25 CET 2011



01.12.2011 10:53, Rafaël Carré пишет:
> Le Thu, 1 Dec 2011 09:13:06 +0700,
> Sergey Radionov<rsatom at gmail.com>  a écrit :
>
>>  From cab0163f1f342909a74cd7d82afd237b14e3e95f Mon Sep 17 00:00:00 2001
>> From: Sergey Radionov<RSATom at gmail.com>
>> Date: Thu, 1 Dec 2011 09:08:23 +0700
>> Subject: [PATCH] npapi: zero NPClass before using.
>>
>> fix #3880
>> ---
>>   npapi/control/nporuntime.h |    1 +
>>   1 files changed, 1 insertions(+), 0 deletions(-)
>>
>> diff --git a/npapi/control/nporuntime.h b/npapi/control/nporuntime.h
>> index 799111a..117c584 100644
>> --- a/npapi/control/nporuntime.h
>> +++ b/npapi/control/nporuntime.h
>> @@ -323,6 +323,7 @@ RuntimeNPClass<T>::RuntimeNPClass()
>>                   T::methodCount, methodIdentifiers);
>>       }
>>
>> +    memset(static_cast<NPClass*>(this), 0, sizeof(NPClass));
>
> Why is that needed, doesn't C++ have default constructors?
ISO/IEC 14882:2003
12.6.2 Initializing bases and members
§4
<..skipped..>
After the call to a constructor for class X has completed, if a member of X is neither specified in the
constructor’s mem-initializers, nor default-initialized, nor value-initialized, nor given a value 
during execution
of the body of the constructor, the member *has indeterminate value*.

>
>>       // fill in NPClass structure
>>       structVersion  = NP_CLASS_STRUCT_VERSION;
>>       allocate       =&RuntimeNPClassAllocate<T>;
>
>
>

-- 
With best wishes,
Sergey Radionov



More information about the vlc-devel mailing list