summaryrefslogtreecommitdiffstatshomepage
path: root/py/runtime.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/py/runtime.c b/py/runtime.c
index 6bc71abff7..0457f0df41 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -775,10 +775,12 @@ mp_obj_t rt_load_attr(mp_obj_t base, qstr attr) {
} else if (MP_OBJ_IS_OBJ(base)) {
// generic method lookup
mp_obj_base_t *o = base;
- const mp_method_t *meth = &o->type->methods[0];
- for (; meth->name != NULL; meth++) {
- if (strcmp(meth->name, qstr_str(attr)) == 0) {
- return mp_obj_new_bound_meth(base, (mp_obj_t)meth->fun);
+ const mp_method_t *meth = o->type->methods;
+ if (meth != NULL) {
+ for (; meth->name != NULL; meth++) {
+ if (strcmp(meth->name, qstr_str(attr)) == 0) {
+ return mp_obj_new_bound_meth(base, (mp_obj_t)meth->fun);
+ }
}
}
}
@@ -799,12 +801,14 @@ void rt_load_method(mp_obj_t base, qstr attr, mp_obj_t *dest) {
} else if (MP_OBJ_IS_OBJ(base)) {
// generic method lookup
mp_obj_base_t *o = base;
- const mp_method_t *meth = &o->type->methods[0];
- for (; meth->name != NULL; meth++) {
- if (strcmp(meth->name, qstr_str(attr)) == 0) {
- dest[1] = (mp_obj_t)meth->fun;
- dest[0] = base;
- return;
+ const mp_method_t *meth = o->type->methods;
+ if (meth != NULL) {
+ for (; meth->name != NULL; meth++) {
+ if (strcmp(meth->name, qstr_str(attr)) == 0) {
+ dest[1] = (mp_obj_t)meth->fun;
+ dest[0] = base;
+ return;
+ }
}
}
}