aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4object.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-10-27 08:54:26 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2014-10-27 15:19:12 +0100
commit57e5407178ce05f577bd032a7bab2508434a4b02 (patch)
treefed4c0d9e82d619c572bd6d86ea1cc9a92436e58 /src/qml/jsruntime/qv4object.cpp
parent8539aa87345fc9a972d9b400fa42fd742b01d4ed (diff)
Don't check the this pointer for 0 in member functions
This actually violates the C++ standard that defines that you aren't allowed to call member functions on an invalid object. Instead insert the 0 pointer checks on the caller side where required. Change-Id: I8be3c3831594bb6482e9ef6de6e590ec437ac0f8 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4object.cpp')
-rw-r--r--src/qml/jsruntime/qv4object.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index d53ca013b4..0c61d666ab 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -244,7 +244,7 @@ Property *Object::__getOwnProperty__(String *name, PropertyAttributes *attrs)
Property *Object::__getOwnProperty__(uint index, PropertyAttributes *attrs)
{
- Property *p = arrayData()->getProperty(index);
+ Property *p = arrayData() ? arrayData()->getProperty(index) : 0;
if (p) {
if (attrs)
*attrs = arrayData()->attributes(index);
@@ -289,7 +289,7 @@ Property *Object::__getPropertyDescriptor__(uint index, PropertyAttributes *attr
{
const Object *o = this;
while (o) {
- Property *p = o->arrayData()->getProperty(index);
+ Property *p = o->arrayData() ? o->arrayData()->getProperty(index) : 0;
if (p) {
if (attrs)
*attrs = o->arrayData()->attributes(index);
@@ -355,7 +355,7 @@ bool Object::hasOwnProperty(String *name) const
bool Object::hasOwnProperty(uint index) const
{
- if (!arrayData()->isEmpty(index))
+ if (arrayData() && !arrayData()->isEmpty(index))
return true;
if (isStringObject()) {
String *s = static_cast<const StringObject *>(this)->d()->value.asString();
@@ -414,7 +414,7 @@ PropertyAttributes Object::query(const Managed *m, String *name)
PropertyAttributes Object::queryIndexed(const Managed *m, uint index)
{
const Object *o = static_cast<const Object *>(m);
- if (o->arrayData()->get(index) != Primitive::emptyValue().asReturnedValue())
+ if (o->arrayData() && o->arrayData()->get(index) != Primitive::emptyValue().asReturnedValue())
return o->arrayData()->attributes(index);
if (o->isStringObject()) {
@@ -618,7 +618,7 @@ ReturnedValue Object::internalGetIndexed(uint index, bool *hasProperty)
PropertyAttributes attrs;
Object *o = this;
while (o) {
- Property *p = o->arrayData()->getProperty(index);
+ Property *p = o->arrayData() ? o->arrayData()->getProperty(index) : 0;
if (p) {
pd = p;
attrs = o->arrayData()->attributes(index);
@@ -738,7 +738,7 @@ void Object::internalPutIndexed(uint index, const ValueRef value)
PropertyAttributes attrs;
- Property *pd = arrayData()->getProperty(index);
+ Property *pd = arrayData() ? arrayData()->getProperty(index) : 0;
if (pd)
attrs = arrayData()->attributes(index);
@@ -925,7 +925,7 @@ bool Object::defineOwnProperty2(ExecutionContext *ctx, uint index, const Propert
Property *current = 0;
// Clause 1
- {
+ if (arrayData()) {
current = arrayData()->getProperty(index);
if (!current && isStringObject())
current = static_cast<StringObject *>(this)->getIndex(index);
@@ -962,12 +962,12 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, String *me
if (attrs.isEmpty())
return true;
- Property *current;
+ Property *current = 0;
PropertyAttributes cattrs;
if (member) {
current = propertyAt(index);
cattrs = internalClass()->propertyData[index];
- } else {
+ } else if (arrayData()) {
current = arrayData()->getProperty(index);
cattrs = arrayData()->attributes(index);
}
@@ -1000,6 +1000,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, String *me
if (!member) {
// need to convert the array and the slot
initSparseArray();
+ Q_ASSERT(arrayData());
setArrayAttributes(index, cattrs);
current = arrayData()->getProperty(index);
}