Skip to content

Commit 390af1f

Browse files
committed
Catch exceptions in VTABLE find_method
The sixmodel VTABLE find_method calls the find_method in the containers STABLE which will throw instead of returning NULL if it can't find the method. Anything which is calling the VTABLE find_method is not going to be expecting an exception so catch any exception and return NULL.
1 parent f7ef779 commit 390af1f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/pmc/sixmodelobject.pmc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
* out (since that depends on the representation).
2323
*/
2424

25+
#include "parrot/exceptions.h"
26+
#include "parrot/events.h"
2527
#include "../6model/sixmodelobject.h"
2628

2729
/* We need to know how to boolify bigints. Really need something better,
@@ -94,8 +96,19 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
9496
}
9597

9698
VTABLE PMC * find_method(STRING *name) {
97-
PMC *decont = decontainerize(interp, SELF);
98-
return STABLE(decont)->find_method(interp, decont, name, NO_HINT);
99+
PMC *m = PMCNULL;
100+
PMC *decont;
101+
Parrot_runloop jmp;
102+
103+
if (!setjmp(jmp.resume)) {
104+
Parrot_ex_add_c_handler(interp, &jmp);
105+
/* try */
106+
decont = decontainerize(interp, SELF);
107+
m = STABLE(decont)->find_method(interp, decont, name, NO_HINT);
108+
}
109+
Parrot_cx_delete_handler_local(interp);
110+
111+
return m;
99112
}
100113

101114
VTABLE PMC* get_attr_keyed(PMC *class_handle, STRING *name) {

0 commit comments

Comments
 (0)