From 949b625377188c087f20c13c73efdfe78f16e446 Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Fri, 2 Mar 2018 14:19:45 -0800 Subject: Don't dereference a null pointer If we don't specifiy an output for R.java, don't try to write data to the class definition Change-Id: I3ad471ec93dcb8baf13f221174065679cce311ad Fixes: 72547268 Test: out/host/linux-x86/nativetest64/aapt2_tests/aapt2_tests --- tools/aapt2/java/JavaClassGenerator_test.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tools/aapt2/java/JavaClassGenerator_test.cpp') diff --git a/tools/aapt2/java/JavaClassGenerator_test.cpp b/tools/aapt2/java/JavaClassGenerator_test.cpp index e449546f9399..10a97d84f59d 100644 --- a/tools/aapt2/java/JavaClassGenerator_test.cpp +++ b/tools/aapt2/java/JavaClassGenerator_test.cpp @@ -438,4 +438,22 @@ TEST(JavaClassGeneratorTest, GenerateOnResourcesLoadedCallbackForSharedLibrary) EXPECT_THAT(output, HasSubstr("com.boo.R.onResourcesLoaded")); } +TEST(JavaClassGeneratorTest, OnlyGenerateRText) { + std::unique_ptr table = + test::ResourceTableBuilder() + .SetPackageId("android", 0x01) + .AddValue("android:attr/foo", ResourceId(0x01010000), util::make_unique()) + .AddValue("android:styleable/hey.dude", ResourceId(0x01020000), + test::StyleableBuilder() + .AddItem("android:attr/foo", ResourceId(0x01010000)) + .Build()) + .Build(); + + std::unique_ptr context = + test::ContextBuilder().SetPackageId(0x01).SetCompilationPackage("android").Build(); + JavaClassGenerator generator(context.get(), table.get(), {}); + + ASSERT_TRUE(generator.Generate("android", nullptr)); +} + } // namespace aapt -- cgit v1.2.3