OSDN Git Service

libvulkan: Don't try to load compressed/unaligned libraries from APK
authorJesse Hall <jessehall@google.com>
Thu, 19 May 2016 17:58:35 +0000 (10:58 -0700)
committerJesse Hall <jessehall@google.com>
Thu, 19 May 2016 23:40:34 +0000 (16:40 -0700)
Bug: 28825642
Change-Id: I46ea3a54010cccf9e23696a4aff52a42a31d92b1

vulkan/libvulkan/layers_extensions.cpp

index aa35657..82169ff 100644 (file)
@@ -366,8 +366,15 @@ void ForEachFileInZip(const std::string& zipname,
             reinterpret_cast<const char*>(name.name) + prefix.length(),
             name.name_length - prefix.length());
         // only enumerate direct entries of the directory, not subdirectories
-        if (filename.find('/') == filename.npos)
-            functor(filename);
+        if (filename.find('/') != filename.npos)
+            continue;
+        // Check whether it *may* be possible to load the library directly from
+        // the APK. Loading still may fail for other reasons, but this at least
+        // lets us avoid failed-to-load log messages in the typical case of
+        // compressed and/or unaligned libraries.
+        if (entry.method != kCompressStored || entry.offset % PAGE_SIZE != 0)
+            continue;
+        functor(filename);
     }
     EndIteration(iter_cookie);
     CloseArchive(zip);