[comparison engine] Don't crash when the context is null
authorDodji Seketeli <dodji@redhat.com>
Fri, 13 Jan 2017 23:56:02 +0000 (00:56 +0100)
committerDodji Seketeli <dodji@redhat.com>
Mon, 16 Jan 2017 20:00:56 +0000 (21:00 +0100)
* src/abg-comparison.cc
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER): Guard against
null context.
(diff::is_filtered_out): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-comparison.cc

index 24822775c68d7c73e936677fd5a4a5b1184a67a9..6f2dc52c11573921fb952a73829eddb97bf02a75 100644 (file)
@@ -191,15 +191,16 @@ operator~(visiting_kind l)
 /// @param S2 the second diff subject to take in account.
 #define RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER(S1, S2) \
   do {                                                                 \
-    if (diff_sptr _diff_ = context()->get_canonical_diff_for(S1, S2))  \
-      if (_diff_->currently_reporting() || _diff_->reported_once())    \
-       {                                                               \
-         if (_diff_->currently_reporting())                            \
-           out << indent << "details are being reported\n";            \
-         else                                                          \
-           out << indent << "details were reported earlier\n"; \
-         return ;                                                      \
-       }                                                               \
+    if (diff_context_sptr ctxt = context())                            \
+      if (diff_sptr _diff_ = ctxt->get_canonical_diff_for(S1, S2))     \
+       if (_diff_->currently_reporting() || _diff_->reported_once())   \
+         {                                                             \
+           if (_diff_->currently_reporting())                          \
+             out << indent << "details are being reported\n";          \
+           else                                                        \
+             out << indent << "details were reported earlier\n";       \
+           return ;                                                    \
+         }                                                             \
   } while (false)
 
 /// This is a subroutine of a *::report() function.
@@ -1433,8 +1434,11 @@ public:
   is_filtered_out(diff_category category)
   {
     diff_context_sptr ctxt = get_context();
+    if (!ctxt)
+      return false;
+
     if (ctxt->get_allowed_category() == EVERYTHING_CATEGORY)
-    return false;
+      return false;
 
   /// We don't want to display nodes suppressed by a user-provided
   /// suppression specification.