Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 39146bcc authored by Donald Chai's avatar Donald Chai Committed by Gerrit Code Review
Browse files

Merge "[aapt2] Fix infinite loop in proguard::CollectLocations"

parents c000664c 34ebc8f4
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -99,11 +99,13 @@ bool CollectLocations(const UsageLocation& location, const KeepSet& keep_set,
//

inline bool operator==(const UsageLocation& lhs, const UsageLocation& rhs) {
  // The "source" member is ignored because we only need "name" for outputting
  // keep rules; "source" is used for comments.
  return lhs.name == rhs.name;
}

inline int operator<(const UsageLocation& lhs, const UsageLocation& rhs) {
  return lhs.name.compare(rhs.name);
inline bool operator<(const UsageLocation& lhs, const UsageLocation& rhs) {
  return lhs.name.compare(rhs.name) < 0;
}

//
+8 −0
Original line number Diff line number Diff line
@@ -364,4 +364,12 @@ TEST(ProguardRulesTest, TransitionRulesAreEmitted) {
    "-keep class com.foo.Bar { <init>(android.content.Context, android.util.AttributeSet); }"));
}

TEST(ProguardRulesTest, UsageLocationComparator) {
  proguard::UsageLocation location1 = {{"pkg", ResourceType::kAttr, "x"}};
  proguard::UsageLocation location2 = {{"pkg", ResourceType::kAttr, "y"}};

  EXPECT_EQ(location1 < location2, true);
  EXPECT_EQ(location2 < location1, false);
}

}  // namespace aapt