diff options
author | Martin Blumenstingl <martin.blumenstingl@googlemail.com> | 2014-05-31 15:50:38 +0200 |
---|---|---|
committer | Martin Blumenstingl <martin.blumenstingl@googlemail.com> | 2014-05-31 16:17:11 +0200 |
commit | 17a24c58bb2e86719f003c80f682beb66803f24d (patch) | |
tree | 0ed75f8f4ed1d31efd4df272715a82ac481f8190 | |
parent | 4f8785f28e6305d427cc3e483248828c9b9b06a2 (diff) | |
download | base-17a24c58bb2e86719f003c80f682beb66803f24d.tar.gz |
MtpDatabase JNI: Fixed a memory-leak in getObjectPropertyValue().
The jstring "stringValue" was not never freed.
In the case where "str" was NULL the whole cleanup part (see "goto out")
was even skipped.
This patch makes getObjectPropertyValue() behave like
getObjectPropertyList().
Change-Id: I5a7ec3611036f5253a054b00064999bcd1d1c29e
-rw-r--r-- | media/jni/android_mtp_MtpDatabase.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/media/jni/android_mtp_MtpDatabase.cpp b/media/jni/android_mtp_MtpDatabase.cpp index 8129c0dfe711..270ab5988f9e 100644 --- a/media/jni/android_mtp_MtpDatabase.cpp +++ b/media/jni/android_mtp_MtpDatabase.cpp @@ -428,16 +428,14 @@ MtpResponseCode MyMtpDatabase::getObjectPropertyValue(MtpObjectHandle handle, case MTP_TYPE_STR: { jstring stringValue = (jstring)env->GetObjectArrayElement(stringValuesArray, 0); + const char* str = (stringValue ? env->GetStringUTFChars(stringValue, NULL) : NULL); if (stringValue) { - const char* str = env->GetStringUTFChars(stringValue, NULL); - if (str == NULL) { - return MTP_RESPONSE_GENERAL_ERROR; - } packet.putString(str); env->ReleaseStringUTFChars(stringValue, str); } else { packet.putEmptyString(); } + env->DeleteLocalRef(stringValue); break; } default: |