From: Alexey Samsonov Date: Thu, 28 Aug 2014 23:17:55 +0000 (+0000) Subject: Don't load ill-formed AmbiguityKind in Sema::Lookup. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=63fa05618abb8971a04938c9f13dbe7b991673fb;p=clang Don't load ill-formed AmbiguityKind in Sema::Lookup. This bug was reported by UBSan. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216695 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/Lookup.h b/include/clang/Sema/Lookup.h index 00cc164d96..e050c7ddbf 100644 --- a/include/clang/Sema/Lookup.h +++ b/include/clang/Sema/Lookup.h @@ -424,13 +424,19 @@ public: Paths = nullptr; } } else { - AmbiguityKind SavedAK = Ambiguity; + AmbiguityKind SavedAK; + bool WasAmbiguous = false; + if (ResultKind == Ambiguous) { + SavedAK = Ambiguity; + WasAmbiguous = true; + } ResultKind = Found; resolveKind(); // If we didn't make the lookup unambiguous, restore the old // ambiguity kind. if (ResultKind == Ambiguous) { + assert(WasAmbiguous); Ambiguity = SavedAK; } else if (Paths) { deletePaths(Paths);