OSDN Git Service

Fix cleanup
authorAndy McFadden <fadden@android.com>
Tue, 1 Nov 2011 18:04:46 +0000 (11:04 -0700)
committerBen Cheng <bccheng@android.com>
Tue, 1 Nov 2011 23:11:43 +0000 (16:11 -0700)
(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

vm/analysis/DexPrepare.cpp

index 7c249ad..174e5f3 100644 (file)
@@ -90,13 +90,13 @@ static bool directoryIsValid(const std::string& fileName)
         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 @@ bail:
     /*
      * 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 @@ bail:
         *ppClassLookup = pClassLookup;
     }
 
-    /* break link between the two */
-    pDvmDex->pDexFile->pClassLookup = NULL;
-
     return result;
 }