Crash fixes, must initialize variants before returning true

This commit is contained in:
Ben Turner 2009-10-08 11:36:50 -07:00
Родитель 0c396d7262
Коммит 07225cf603
2 изменённых файлов: 46 добавлений и 18 удалений

Просмотреть файл

@ -698,10 +698,9 @@ PluginScriptableObjectChild::AnswerInvoke(const NPRemoteIdentifier& aId,
Variant* aResult, Variant* aResult,
bool* aSuccess) bool* aSuccess)
{ {
*aResult = null_t();
if (!mObject) { if (!mObject) {
NS_WARNING("Calling AnswerInvoke with an invalidated object!"); NS_WARNING("Calling AnswerInvoke with an invalidated object!");
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -709,6 +708,7 @@ PluginScriptableObjectChild::AnswerInvoke(const NPRemoteIdentifier& aId,
NS_ASSERTION(mObject->_class != GetClass(), "Bad object type!"); NS_ASSERTION(mObject->_class != GetClass(), "Bad object type!");
if (!(mObject->_class && mObject->_class->invoke)) { if (!(mObject->_class && mObject->_class->invoke)) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -717,6 +717,7 @@ PluginScriptableObjectChild::AnswerInvoke(const NPRemoteIdentifier& aId,
PRUint32 argCount = aArgs.Length(); PRUint32 argCount = aArgs.Length();
if (!convertedArgs.SetLength(argCount)) { if (!convertedArgs.SetLength(argCount)) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -735,6 +736,7 @@ PluginScriptableObjectChild::AnswerInvoke(const NPRemoteIdentifier& aId,
} }
if (!success) { if (!success) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -745,6 +747,7 @@ PluginScriptableObjectChild::AnswerInvoke(const NPRemoteIdentifier& aId,
PluginModuleChild::sBrowserFuncs.releasevariantvalue(&result); PluginModuleChild::sBrowserFuncs.releasevariantvalue(&result);
if (!success) { if (!success) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -759,10 +762,9 @@ PluginScriptableObjectChild::AnswerInvokeDefault(const nsTArray<Variant>& aArgs,
Variant* aResult, Variant* aResult,
bool* aSuccess) bool* aSuccess)
{ {
*aResult = null_t();
if (!mObject) { if (!mObject) {
NS_WARNING("Calling AnswerInvokeDefault with an invalidated object!"); NS_WARNING("Calling AnswerInvokeDefault with an invalidated object!");
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -770,6 +772,7 @@ PluginScriptableObjectChild::AnswerInvokeDefault(const nsTArray<Variant>& aArgs,
NS_ASSERTION(mObject->_class != GetClass(), "Bad object type!"); NS_ASSERTION(mObject->_class != GetClass(), "Bad object type!");
if (!(mObject->_class && mObject->_class->invokeDefault)) { if (!(mObject->_class && mObject->_class->invokeDefault)) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -778,6 +781,7 @@ PluginScriptableObjectChild::AnswerInvokeDefault(const nsTArray<Variant>& aArgs,
PRUint32 argCount = aArgs.Length(); PRUint32 argCount = aArgs.Length();
if (!convertedArgs.SetLength(argCount)) { if (!convertedArgs.SetLength(argCount)) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -796,6 +800,7 @@ PluginScriptableObjectChild::AnswerInvokeDefault(const nsTArray<Variant>& aArgs,
} }
if (!success) { if (!success) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -806,12 +811,13 @@ PluginScriptableObjectChild::AnswerInvokeDefault(const nsTArray<Variant>& aArgs,
PluginModuleChild::sBrowserFuncs.releasevariantvalue(&result); PluginModuleChild::sBrowserFuncs.releasevariantvalue(&result);
if (!success) { if (!success) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
*aSuccess = true;
*aResult = convertedResult; *aResult = convertedResult;
*aSuccess = true;
return true; return true;
} }
@ -967,10 +973,9 @@ PluginScriptableObjectChild::AnswerConstruct(const nsTArray<Variant>& aArgs,
Variant* aResult, Variant* aResult,
bool* aSuccess) bool* aSuccess)
{ {
*aResult = null_t();
if (!mObject) { if (!mObject) {
NS_WARNING("Calling AnswerConstruct with an invalidated object!"); NS_WARNING("Calling AnswerConstruct with an invalidated object!");
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -978,6 +983,7 @@ PluginScriptableObjectChild::AnswerConstruct(const nsTArray<Variant>& aArgs,
NS_ASSERTION(mObject->_class != GetClass(), "Bad object type!"); NS_ASSERTION(mObject->_class != GetClass(), "Bad object type!");
if (!(mObject->_class && mObject->_class->construct)) { if (!(mObject->_class && mObject->_class->construct)) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -986,6 +992,7 @@ PluginScriptableObjectChild::AnswerConstruct(const nsTArray<Variant>& aArgs,
PRUint32 argCount = aArgs.Length(); PRUint32 argCount = aArgs.Length();
if (!convertedArgs.SetLength(argCount)) { if (!convertedArgs.SetLength(argCount)) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -1003,6 +1010,7 @@ PluginScriptableObjectChild::AnswerConstruct(const nsTArray<Variant>& aArgs,
} }
if (!success) { if (!success) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -1013,11 +1021,12 @@ PluginScriptableObjectChild::AnswerConstruct(const nsTArray<Variant>& aArgs,
PluginModuleChild::sBrowserFuncs.releasevariantvalue(&result); PluginModuleChild::sBrowserFuncs.releasevariantvalue(&result);
if (!success) { if (!success) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
*aSuccess = true;
*aResult = convertedResult; *aResult = convertedResult;
*aSuccess = true;
return true; return true;
} }

Просмотреть файл

@ -854,10 +854,9 @@ PluginScriptableObjectParent::AnswerInvoke(const NPRemoteIdentifier& aId,
Variant* aResult, Variant* aResult,
bool* aSuccess) bool* aSuccess)
{ {
*aResult = void_t();
if (!mObject) { if (!mObject) {
NS_WARNING("Calling AnswerInvoke with an invalidated object!"); NS_WARNING("Calling AnswerInvoke with an invalidated object!");
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -867,6 +866,7 @@ PluginScriptableObjectParent::AnswerInvoke(const NPRemoteIdentifier& aId,
PluginInstanceParent* instance = GetInstance(); PluginInstanceParent* instance = GetInstance();
if (!instance) { if (!instance) {
NS_ERROR("No instance?!"); NS_ERROR("No instance?!");
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -874,12 +874,14 @@ PluginScriptableObjectParent::AnswerInvoke(const NPRemoteIdentifier& aId,
const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance); const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
if (!npn) { if (!npn) {
NS_ERROR("No netscape funcs?!"); NS_ERROR("No netscape funcs?!");
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
if (!EnsureValidIdentifier(instance, (NPIdentifier)aId)) { if (!EnsureValidIdentifier(instance, (NPIdentifier)aId)) {
NS_WARNING("Invalid NPIdentifier!"); NS_WARNING("Invalid NPIdentifier!");
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -888,6 +890,7 @@ PluginScriptableObjectParent::AnswerInvoke(const NPRemoteIdentifier& aId,
PRUint32 argCount = aArgs.Length(); PRUint32 argCount = aArgs.Length();
if (!convertedArgs.SetLength(argCount)) { if (!convertedArgs.SetLength(argCount)) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -898,6 +901,7 @@ PluginScriptableObjectParent::AnswerInvoke(const NPRemoteIdentifier& aId,
while (index-- > 0) { while (index-- > 0) {
ReleaseVariant(convertedArgs[index], instance); ReleaseVariant(convertedArgs[index], instance);
} }
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -912,6 +916,7 @@ PluginScriptableObjectParent::AnswerInvoke(const NPRemoteIdentifier& aId,
} }
if (!success) { if (!success) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -922,12 +927,13 @@ PluginScriptableObjectParent::AnswerInvoke(const NPRemoteIdentifier& aId,
ReleaseVariant(result, instance); ReleaseVariant(result, instance);
if (!success) { if (!success) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
*aSuccess = true;
*aResult = convertedResult; *aResult = convertedResult;
*aSuccess = true;
return true; return true;
} }
@ -936,10 +942,9 @@ PluginScriptableObjectParent::AnswerInvokeDefault(const nsTArray<Variant>& aArgs
Variant* aResult, Variant* aResult,
bool* aSuccess) bool* aSuccess)
{ {
*aResult = void_t();
if (!mObject) { if (!mObject) {
NS_WARNING("Calling AnswerInvoke with an invalidated object!"); NS_WARNING("Calling AnswerInvoke with an invalidated object!");
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -949,6 +954,7 @@ PluginScriptableObjectParent::AnswerInvokeDefault(const nsTArray<Variant>& aArgs
PluginInstanceParent* instance = GetInstance(); PluginInstanceParent* instance = GetInstance();
if (!instance) { if (!instance) {
NS_ERROR("No instance?!"); NS_ERROR("No instance?!");
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -956,6 +962,7 @@ PluginScriptableObjectParent::AnswerInvokeDefault(const nsTArray<Variant>& aArgs
const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance); const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
if (!npn) { if (!npn) {
NS_ERROR("No netscape funcs?!"); NS_ERROR("No netscape funcs?!");
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -964,6 +971,7 @@ PluginScriptableObjectParent::AnswerInvokeDefault(const nsTArray<Variant>& aArgs
PRUint32 argCount = aArgs.Length(); PRUint32 argCount = aArgs.Length();
if (!convertedArgs.SetLength(argCount)) { if (!convertedArgs.SetLength(argCount)) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -974,6 +982,7 @@ PluginScriptableObjectParent::AnswerInvokeDefault(const nsTArray<Variant>& aArgs
while (index-- > 0) { while (index-- > 0) {
ReleaseVariant(convertedArgs[index], instance); ReleaseVariant(convertedArgs[index], instance);
} }
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -989,6 +998,7 @@ PluginScriptableObjectParent::AnswerInvokeDefault(const nsTArray<Variant>& aArgs
} }
if (!success) { if (!success) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -999,12 +1009,13 @@ PluginScriptableObjectParent::AnswerInvokeDefault(const nsTArray<Variant>& aArgs
ReleaseVariant(result, instance); ReleaseVariant(result, instance);
if (!success) { if (!success) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
*aSuccess = true;
*aResult = convertedResult; *aResult = convertedResult;
*aSuccess = true;
return true; return true;
} }
@ -1050,10 +1061,9 @@ PluginScriptableObjectParent::AnswerGetProperty(const NPRemoteIdentifier& aId,
Variant* aResult, Variant* aResult,
bool* aSuccess) bool* aSuccess)
{ {
*aResult = void_t();
if (!mObject) { if (!mObject) {
NS_WARNING("Calling AnswerGetProperty with an invalidated object!"); NS_WARNING("Calling AnswerGetProperty with an invalidated object!");
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -1063,6 +1073,7 @@ PluginScriptableObjectParent::AnswerGetProperty(const NPRemoteIdentifier& aId,
PluginInstanceParent* instance = GetInstance(); PluginInstanceParent* instance = GetInstance();
if (!instance) { if (!instance) {
NS_ERROR("No instance?!"); NS_ERROR("No instance?!");
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -1070,12 +1081,14 @@ PluginScriptableObjectParent::AnswerGetProperty(const NPRemoteIdentifier& aId,
const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance); const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
if (!npn) { if (!npn) {
NS_ERROR("No netscape funcs?!"); NS_ERROR("No netscape funcs?!");
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
if (!EnsureValidIdentifier(instance, (NPIdentifier)aId)) { if (!EnsureValidIdentifier(instance, (NPIdentifier)aId)) {
NS_WARNING("Invalid NPIdentifier!"); NS_WARNING("Invalid NPIdentifier!");
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -1083,6 +1096,7 @@ PluginScriptableObjectParent::AnswerGetProperty(const NPRemoteIdentifier& aId,
NPVariant result; NPVariant result;
if (!npn->getproperty(instance->GetNPP(), mObject, (NPIdentifier)aId, if (!npn->getproperty(instance->GetNPP(), mObject, (NPIdentifier)aId,
&result)) { &result)) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -1237,10 +1251,9 @@ PluginScriptableObjectParent::AnswerConstruct(const nsTArray<Variant>& aArgs,
Variant* aResult, Variant* aResult,
bool* aSuccess) bool* aSuccess)
{ {
*aResult = void_t();
if (!mObject) { if (!mObject) {
NS_WARNING("Calling AnswerConstruct with an invalidated object!"); NS_WARNING("Calling AnswerConstruct with an invalidated object!");
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -1250,6 +1263,7 @@ PluginScriptableObjectParent::AnswerConstruct(const nsTArray<Variant>& aArgs,
PluginInstanceParent* instance = GetInstance(); PluginInstanceParent* instance = GetInstance();
if (!instance) { if (!instance) {
NS_ERROR("No instance?!"); NS_ERROR("No instance?!");
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -1257,6 +1271,7 @@ PluginScriptableObjectParent::AnswerConstruct(const nsTArray<Variant>& aArgs,
const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance); const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
if (!npn) { if (!npn) {
NS_ERROR("No netscape funcs?!"); NS_ERROR("No netscape funcs?!");
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -1265,6 +1280,7 @@ PluginScriptableObjectParent::AnswerConstruct(const nsTArray<Variant>& aArgs,
PRUint32 argCount = aArgs.Length(); PRUint32 argCount = aArgs.Length();
if (!convertedArgs.SetLength(argCount)) { if (!convertedArgs.SetLength(argCount)) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -1275,6 +1291,7 @@ PluginScriptableObjectParent::AnswerConstruct(const nsTArray<Variant>& aArgs,
while (index-- > 0) { while (index-- > 0) {
ReleaseVariant(convertedArgs[index], instance); ReleaseVariant(convertedArgs[index], instance);
} }
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -1289,6 +1306,7 @@ PluginScriptableObjectParent::AnswerConstruct(const nsTArray<Variant>& aArgs,
} }
if (!success) { if (!success) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }
@ -1299,6 +1317,7 @@ PluginScriptableObjectParent::AnswerConstruct(const nsTArray<Variant>& aArgs,
ReleaseVariant(result, instance); ReleaseVariant(result, instance);
if (!success) { if (!success) {
*aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
} }