From 06db1895ffa097388ad55e2c2dbb6aa960411734 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Thu, 16 Oct 2014 22:38:04 +0200 Subject: [PATCH] Avoid infinite loops in the comparison code for classes * src/abg-ir.cc (equals): In the overload for classes, make sure to store the name of the lhs of the class and the rhs into the lhs. Also, when we bail out because we detect that there is a comparison underway, do *not* unmark the current class as not being involved in the comparison. Also, break at the first lhs virtual member function that is different from the rhs counter part. Signed-off-by: Dodji Seketeli --- src/abg-ir.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/abg-ir.cc b/src/abg-ir.cc index c1748629..e16e4aa8 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -6818,8 +6818,8 @@ equals(const class_decl& l, const class_decl& r, change_kind& k) { #define RETURN(value) \ do { \ - l.priv_->unmark_as_being_compared(&l); \ - l.priv_->unmark_as_being_compared(&r); \ + l.priv_->unmark_as_being_compared(l); \ + l.priv_->unmark_as_being_compared(r); \ return value; \ } while(0) @@ -6850,9 +6850,9 @@ equals(const class_decl& l, const class_decl& r, change_kind& k) RETURN(true); } - if (l.priv_->comparison_started(&l) - || l.priv_->comparison_started(&r)) - RETURN(true); + if (l.priv_->comparison_started(l) + || l.priv_->comparison_started(r)) + return true; l.priv_->mark_as_being_compared(l); l.priv_->mark_as_being_compared(r); @@ -6871,12 +6871,12 @@ equals(const class_decl& l, const class_decl& r, change_kind& k) RETURN(false); } - if (l.priv_->comparison_started(&l) - || l.priv_->comparison_started(&r)) - RETURN(true); + if (l.priv_->comparison_started(l) + || l.priv_->comparison_started(r)) + return true; - l.priv_->mark_as_being_compared(&l); - l.priv_->mark_as_being_compared(&r); + l.priv_->mark_as_being_compared(l); + l.priv_->mark_as_being_compared(r); bool result = true; @@ -6943,6 +6943,7 @@ equals(const class_decl& l, const class_decl& r, change_kind& k) { k |= SUBTYPE_CHANGE_KIND; result = false; + break; } }