Merge "Define `ANDROID_RUNTIME_ROOT` as `$ANDROID_ROOT` on target in the `art` script."
diff --git a/build/apex/ld.config.txt b/build/apex/ld.config.txt
index 014b115..9e49d76 100644
--- a/build/apex/ld.config.txt
+++ b/build/apex/ld.config.txt
@@ -24,8 +24,7 @@
 namespace.platform.isolated = true
 namespace.platform.search.paths = /system/${LIB}
 namespace.platform.links = default
-namespace.platform.link.default.shared_libs  = libc.so:libdl.so:libm.so
-namespace.platform.link.default.shared_libs += libart.so:libartd.so
+namespace.platform.link.default.shared_libs  = libart.so:libartd.so
 namespace.platform.link.default.shared_libs += libnativebridge.so
 namespace.platform.link.default.shared_libs += libnativehelper.so
 namespace.platform.link.default.shared_libs += libnativeloader.so
diff --git a/libdexfile/external/dex_file_ext_c_test.c b/libdexfile/external/dex_file_ext_c_test.c
index ad0737a..85cd46e 100644
--- a/libdexfile/external/dex_file_ext_c_test.c
+++ b/libdexfile/external/dex_file_ext_c_test.c
@@ -36,6 +36,7 @@
   }
   if (fprintf(output_fd, gtest_output_xml) != sizeof(gtest_output_xml) - 1) {
     fprintf(stderr, "Failed to write %s: %s\n", gtest_output_path, strerror(errno));
+    fclose(output_fd);
     return 1;
   }
   if (fclose(output_fd) != 0) {
diff --git a/libdexfile/external/dex_file_supp_test.cc b/libdexfile/external/dex_file_supp_test.cc
index 3dd08c0..2f7ad50 100644
--- a/libdexfile/external/dex_file_supp_test.cc
+++ b/libdexfile/external/dex_file_supp_test.cc
@@ -75,6 +75,12 @@
   EXPECT_EQ(std::string_view(s2), "foo");
 }
 
+TEST(DexStringTest, reassign) {
+  auto s = DexString("foo");
+  s = DexString("bar");
+  EXPECT_EQ(std::string_view(s), "bar");
+}
+
 TEST(DexStringTest, data_access) {
   auto s = DexString("foo");
   EXPECT_STREQ(s.data(), "foo");
@@ -272,7 +278,7 @@
   std::unique_ptr<DexFile> dex_file = GetTestDexData();
   ASSERT_NE(dex_file, nullptr);
 
-  auto df1 = DexFile(std::move(*dex_file.release()));
+  auto df1 = DexFile(std::move(*dex_file));
   auto df2 = DexFile(std::move(df1));
 
   MethodInfo info = df2.GetMethodInfoForOffset(0x100, false);
diff --git a/libdexfile/external/include/art_api/dex_file_support.h b/libdexfile/external/include/art_api/dex_file_support.h
index ddd9143..24222af 100644
--- a/libdexfile/external/include/art_api/dex_file_support.h
+++ b/libdexfile/external/include/art_api/dex_file_support.h
@@ -23,6 +23,7 @@
 #include <memory>
 #include <string>
 #include <string_view>
+#include <utility>
 #include <vector>
 
 #include <android-base/macros.h>
@@ -35,7 +36,9 @@
 // Minimal std::string look-alike for a string returned from libdexfile.
 class DexString final {
  public:
-  DexString(DexString&& dex_str) noexcept { ReplaceExtString(std::move(dex_str)); }
+  DexString(DexString&& dex_str) noexcept : ext_string_(dex_str.ext_string_) {
+    dex_str.ext_string_ = ExtDexFileMakeString("", 0);
+  }
   explicit DexString(const char* str = "")
       : ext_string_(ExtDexFileMakeString(str, std::strlen(str))) {}
   explicit DexString(std::string_view str)
@@ -43,7 +46,7 @@
   ~DexString() { ExtDexFileFreeString(ext_string_); }
 
   DexString& operator=(DexString&& dex_str) noexcept {
-    ReplaceExtString(std::move(dex_str));
+    std::swap(ext_string_, dex_str.ext_string_);
     return *this;
   }
 
@@ -72,11 +75,6 @@
   explicit DexString(const ExtDexFileString* ext_string) : ext_string_(ext_string) {}
   const ExtDexFileString* ext_string_;  // Owned instance. Never nullptr.
 
-  void ReplaceExtString(DexString&& dex_str) {
-    ext_string_ = dex_str.ext_string_;
-    dex_str.ext_string_ = ExtDexFileMakeString("", 0);
-  }
-
   DISALLOW_COPY_AND_ASSIGN(DexString);
 };