diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-07 15:58:30 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-07 15:58:30 +0000 |
commit | 97209d38e17a0f3cb2a2d3f03d726fd322b4808f (patch) | |
tree | 514cc35179713b4128ec6218829d769d87d7fe70 /py/runtime.c | |
parent | d49420e74c721bb6c61925a6c9a2addbaeed3382 (diff) | |
parent | a5a01df81d01705b9f04264cc46fbb1bc32641b3 (diff) | |
download | micropython-97209d38e17a0f3cb2a2d3f03d726fd322b4808f.tar.gz micropython-97209d38e17a0f3cb2a2d3f03d726fd322b4808f.zip |
Merge branch 'cplusplus' of https://github.com/ian-v/micropython into ian-v-cplusplus
Conflicts:
py/objcomplex.c
Diffstat (limited to 'py/runtime.c')
-rw-r--r-- | py/runtime.c | 24 |
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; + } } } } |