py/repl: Use mp_load_method_protected to prevent leaking of exceptions.
This patch fixes the possibility of a crash of the REPL when tab-completing an object which raises an exception when its attributes are accessed. See issue #3729.
This commit is contained in:
parent
529860643b
commit
7241d90272
@ -158,7 +158,7 @@ size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print
|
|||||||
// lookup will fail
|
// lookup will fail
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
mp_load_method_maybe(obj, q, dest);
|
mp_load_method_protected(obj, q, dest, true);
|
||||||
obj = dest[0]; // attribute, method, or MP_OBJ_NULL if nothing found
|
obj = dest[0]; // attribute, method, or MP_OBJ_NULL if nothing found
|
||||||
|
|
||||||
if (obj == MP_OBJ_NULL) {
|
if (obj == MP_OBJ_NULL) {
|
||||||
@ -180,7 +180,7 @@ size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print
|
|||||||
size_t d_len;
|
size_t d_len;
|
||||||
const char *d_str = (const char*)qstr_data(q, &d_len);
|
const char *d_str = (const char*)qstr_data(q, &d_len);
|
||||||
if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) {
|
if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) {
|
||||||
mp_load_method_maybe(obj, q, dest);
|
mp_load_method_protected(obj, q, dest, true);
|
||||||
if (dest[0] != MP_OBJ_NULL) {
|
if (dest[0] != MP_OBJ_NULL) {
|
||||||
if (match_str == NULL) {
|
if (match_str == NULL) {
|
||||||
match_str = d_str;
|
match_str = d_str;
|
||||||
@ -234,7 +234,7 @@ size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print
|
|||||||
size_t d_len;
|
size_t d_len;
|
||||||
const char *d_str = (const char*)qstr_data(q, &d_len);
|
const char *d_str = (const char*)qstr_data(q, &d_len);
|
||||||
if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) {
|
if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) {
|
||||||
mp_load_method_maybe(obj, q, dest);
|
mp_load_method_protected(obj, q, dest, true);
|
||||||
if (dest[0] != MP_OBJ_NULL) {
|
if (dest[0] != MP_OBJ_NULL) {
|
||||||
int gap = (line_len + WORD_SLOT_LEN - 1) / WORD_SLOT_LEN * WORD_SLOT_LEN - line_len;
|
int gap = (line_len + WORD_SLOT_LEN - 1) / WORD_SLOT_LEN * WORD_SLOT_LEN - line_len;
|
||||||
if (gap < 2) {
|
if (gap < 2) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user