Merge "StrictJarFile can use the new std::string libziparchive Next overload." am: 9fa4e0442c

am: d5a3817eef

Change-Id: I7064fd27f43b5e5790e128cc2ed0a753df5da4b7
This commit is contained in:
Elliott Hughes
2019-05-24 13:22:25 -07:00
committed by android-build-merger

View File

@@ -112,7 +112,7 @@ jlong StrictJarFile_nativeStartIteration(JNIEnv* env, jobject, jlong nativeHandl
jobject StrictJarFile_nativeNextEntry(JNIEnv* env, jobject, jlong iterationHandle) { jobject StrictJarFile_nativeNextEntry(JNIEnv* env, jobject, jlong iterationHandle) {
ZipEntry data; ZipEntry data;
ZipString entryName; std::string entryName;
IterationHandle* handle = reinterpret_cast<IterationHandle*>(iterationHandle); IterationHandle* handle = reinterpret_cast<IterationHandle*>(iterationHandle);
const int32_t error = Next(*handle->CookieAddress(), &data, &entryName); const int32_t error = Next(*handle->CookieAddress(), &data, &entryName);
@@ -121,10 +121,7 @@ jobject StrictJarFile_nativeNextEntry(JNIEnv* env, jobject, jlong iterationHandl
return NULL; return NULL;
} }
std::unique_ptr<char[]> entryNameCString(new char[entryName.name_length + 1]); ScopedLocalRef<jstring> entryNameString(env, env->NewStringUTF(entryName.c_str()));
memcpy(entryNameCString.get(), entryName.name, entryName.name_length);
entryNameCString[entryName.name_length] = '\0';
ScopedLocalRef<jstring> entryNameString(env, env->NewStringUTF(entryNameCString.get()));
return newZipEntry(env, data, entryNameString.get()); return newZipEntry(env, data, entryNameString.get());
} }