Fix cleanup
(cherry-picked from ics-mr1)
The code was attempting to null out a struct member after freeing
the struct.
Also, changed the order of directory permission tests so that
writable comes first. Somehow "dalvik-cache directory not
writable" seems more direct than "not readable", since the code
isn't generally interested in reading the directory.
Bug 5549907
Change-Id: If737ab822b356aae98e47292d21946e33a04342b
diff --git a/vm/analysis/DexPrepare.cpp b/vm/analysis/DexPrepare.cpp
index 7c249ad..174e5f3 100644
--- a/vm/analysis/DexPrepare.cpp
+++ b/vm/analysis/DexPrepare.cpp
@@ -90,13 +90,13 @@
return false;
}
- if (access(dirName.c_str(), R_OK) < 0) {
- LOGE("Dex cache directory isn't readable: %s", dirName.c_str());
+ if (access(dirName.c_str(), W_OK) < 0) {
+ LOGE("Dex cache directory isn't writable: %s", dirName.c_str());
return false;
}
- if (access(dirName.c_str(), W_OK) < 0) {
- LOGE("Dex cache directory isn't writable: %s", dirName.c_str());
+ if (access(dirName.c_str(), R_OK) < 0) {
+ LOGE("Dex cache directory isn't readable: %s", dirName.c_str());
return false;
}
@@ -881,6 +881,12 @@
/*
* On success, return the pieces that the caller asked for.
*/
+
+ if (pDvmDex != NULL) {
+ /* break link between the two */
+ pDvmDex->pDexFile->pClassLookup = NULL;
+ }
+
if (ppDvmDex == NULL || !result) {
dvmDexFileFree(pDvmDex);
} else {
@@ -893,9 +899,6 @@
*ppClassLookup = pClassLookup;
}
- /* break link between the two */
- pDvmDex->pDexFile->pClassLookup = NULL;
-
return result;
}