A new check for -> on ManagedTypes.
This commit is contained in:
parent
74542e66eb
commit
b421ba5b69
2 changed files with 6 additions and 1 deletions
|
@ -45,6 +45,9 @@ enum PanicCode{
|
|||
MICROBIT_OOM = 20,
|
||||
|
||||
// Corruption detected in the micro:bit heap space
|
||||
MICROBIT_HEAP_ERROR = 30
|
||||
MICROBIT_HEAP_ERROR = 30,
|
||||
|
||||
// Dereference of a NULL pointer through the ManagedType class,
|
||||
MICROBIT_NULL_DEREFERENCE = 40,
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -103,6 +103,8 @@ public:
|
|||
* x->m(); // resolves to T::m
|
||||
*/
|
||||
T* operator->() {
|
||||
if (object == NULL)
|
||||
panic(MICROBIT_NULL_DEREFERENCE);
|
||||
return object;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue