From: Andy McFadden Date: Tue, 1 Nov 2011 18:04:46 +0000 (-0700) Subject: Fix cleanup X-Git-Tag: android-x86-4.0-r1~41^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=3931f79801b67577bf8ac12d0b3fb5b4aeaaf766;p=android-x86%2Fdalvik.git 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 7c249ad86..174e5f353 100644 --- a/vm/analysis/DexPrepare.cpp +++ b/vm/analysis/DexPrepare.cpp @@ -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; }