[totem] Fix property/method name lookup
- From: Bastien Nocera <hadess src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [totem] Fix property/method name lookup
- Date: Thu, 19 Nov 2009 15:13:07 +0000 (UTC)
commit 183b9c1b0aff35b7f15c2f809f1a7c028eedf704
Author: Christian Persch <chpe gnome org>
Date: Wed Nov 18 18:54:43 2009 +0100
Fix property/method name lookup
Don't read the arrays out of bounds! Bug #560946 comment 12.
browser-plugin/totemNPClass.cpp | 6 ++++--
browser-plugin/totemNPObject.cpp | 10 ++++++----
2 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/browser-plugin/totemNPClass.cpp b/browser-plugin/totemNPClass.cpp
index 224b1c9..d32a274 100644
--- a/browser-plugin/totemNPClass.cpp
+++ b/browser-plugin/totemNPClass.cpp
@@ -29,7 +29,9 @@ totemNPClass_base::totemNPClass_base (const char *aPropertNames[],
uint32_t aMethodCount,
const char *aDefaultMethodName) :
mPropertyNameIdentifiers (GetIdentifiersForNames (aPropertNames, aPropertyCount)),
+ mPropertyNamesCount (aPropertyCount),
mMethodNameIdentifiers (GetIdentifiersForNames (aMethodNames, aMethodCount)),
+ mMethodNamesCount (aMethodCount),
mDefaultMethodIndex (aDefaultMethodName ? GetMethodIndex (NPN_GetStringIdentifier (aDefaultMethodName)) : -1)
{
structVersion = NP_CLASS_STRUCT_VERSION_ENUM;
@@ -81,7 +83,7 @@ totemNPClass_base::GetPropertyIndex (NPIdentifier aName)
if (!mPropertyNameIdentifiers)
return -1;
- for (int i = 0; mPropertyNameIdentifiers[i]; ++i) {
+ for (int i = 0; i < mPropertyNamesCount; ++i) {
if (aName == mPropertyNameIdentifiers[i])
return i;
}
@@ -95,7 +97,7 @@ totemNPClass_base::GetMethodIndex (NPIdentifier aName)
if (!mMethodNameIdentifiers)
return -1;
- for (int i = 0; mMethodNameIdentifiers[i]; ++i) {
+ for (int i = 0; i < mMethodNamesCount; ++i) {
if (aName == mMethodNameIdentifiers[i])
return i;
}
diff --git a/browser-plugin/totemNPObject.cpp b/browser-plugin/totemNPObject.cpp
index 8e8d403..0c6394b 100644
--- a/browser-plugin/totemNPObject.cpp
+++ b/browser-plugin/totemNPObject.cpp
@@ -416,8 +416,9 @@ totemNPObject::HasMethod (NPIdentifier aName)
if (!IsValid ())
return false;
- NOTE (g_print ("totemNPObject::HasMethod [%p] %s\n", (void*) this, NPN_UTF8FromIdentifier (aName)));
- if (GetClass()->GetMethodIndex (aName) >= 0)
+ int methodIndex = GetClass()->GetMethodIndex (aName);
+ NOTE (g_print ("totemNPObject::HasMethod [%p] %s => %s\n", (void*) this, NPN_UTF8FromIdentifier (aName), methodIndex >= 0 ? "yes" : "no"));
+ if (methodIndex >= 0)
return true;
if (aName == NPN_GetStringIdentifier ("__noSuchMethod__"))
@@ -478,8 +479,9 @@ totemNPObject::HasProperty (NPIdentifier aName)
if (!IsValid ())
return false;
- NOTE (g_print ("totemNPObject::HasProperty [%p] %s\n", (void*) this, NPN_UTF8FromIdentifier (aName)));
- if (GetClass()->GetPropertyIndex (aName) >= 0)
+ int propertyIndex = GetClass()->GetPropertyIndex (aName);
+ NOTE (g_print ("totemNPObject::HasProperty [%p] %s => %s\n", (void*) this, NPN_UTF8FromIdentifier (aName), propertyIndex >= 0 ? "yes" : "no"));
+ if (propertyIndex >= 0)
return true;
return false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]