From fa155aea7c2c39b863f676a8285fdb16a726fa91 Mon Sep 17 00:00:00 2001 From: Arne Goedeke <el@laramies.com> Date: Tue, 27 Jan 2015 17:50:23 +0100 Subject: [PATCH] equal: allow comparing objects with getters setters/getters are marked as variables with special run_time_type. object_equal_p() did not handle that case and ended up calling low_is_equal with type PIKE_T_GET_SET which would lead to a fatal. This change makes object_equal_p() ignore getters. --- src/object.c | 5 +++++ src/testsuite.in | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/object.c b/src/object.c index e930f1f6d8..645cd56db6 100644 --- a/src/object.c +++ b/src/object.c @@ -1953,6 +1953,11 @@ PMOD_EXPORT int object_equal_p(struct object *a, struct object *b, struct proces IDENTIFIER_IS_ALIAS(i->identifier_flags)) continue; + /* Do we want to call getters and compare their return values? + * - arne + */ + if (i->run_time_type == PIKE_T_GET_SET) continue; + if(i->run_time_type == T_MIXED) { if(!low_is_equal((struct svalue *)LOW_GET_GLOBAL(a,e,i), diff --git a/src/testsuite.in b/src/testsuite.in index cf1bc945f0..d488c37945 100644 --- a/src/testsuite.in +++ b/src/testsuite.in @@ -4085,6 +4085,16 @@ test_any([[ return Y(5)->x; ]], 7) +test_any([[ + // Triggered fatal since object_equal_p did not handle + // getter/setter identifier correctly + class A { + string `foo() { return "bar"; } + } + + return equal(A(), A()); +]], 1) + test_eval_error([[ // Triggered infinite recursion and core dump. // cf LysLysKOM 18719518/Pike mailinglist 12047. -- GitLab