lightspark/lightspark — Issue #131: getVariableByMultiname() should return a new reference
Author: aajanki
Created: 2011-10-17 18:39:44+00:00
State: open

ASObject::getVariableByMultiname() should incRef the returned object and the caller should be responsible for decReffing it.

Currently, it is assumed that getVariableByMultiname() returns a pointer to an existing property of the object and therefore getVariableByMultiname() can return a borrowed reference. However, there are cases when getVariableByMultiname() actually returns a new instance. For example, getters can construct new objects (see ASPROPERTY_GETTER macro). Similarly, getting properties of XMLs or Arrays returns dynamically constructed objects.

At the moment, when getVariableByMultiname() allocates a new object, it will be leaked because no-one is responsible for releasing it. Some code paths in getVariableByMultiname() even fake_decRef() the return value, which can cause false assertion errors in ASObject::check() if fake_decRef() decreases the reference count to zero.