A new check for -> on ManagedTypes.

master v1.3.5
Jonathan Protzenko 8 years ago
parent 74542e66eb
commit b421ba5b69

@ -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…
Cancel
Save