Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArsentiy Milchakov <milcars@mapswithme.com>2016-12-12 13:13:57 +0300
committerArsentiy Milchakov <milcars@mapswithme.com>2016-12-12 13:13:57 +0300
commit82cacdbd1645b84200d42039729f49f6e93b5048 (patch)
tree78156522e35bd7482e131309d115748ae6b8367c /android
parentbd675c6b08cd7eda774548474a32787f2a96963a (diff)
[android] http client leaks fix
Diffstat (limited to 'android')
-rw-r--r--android/jni/com/mapswithme/util/HttpClient.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/android/jni/com/mapswithme/util/HttpClient.cpp b/android/jni/com/mapswithme/util/HttpClient.cpp
index f5cc434b7b..ae631514e6 100644
--- a/android/jni/com/mapswithme/util/HttpClient.cpp
+++ b/android/jni/com/mapswithme/util/HttpClient.cpp
@@ -131,21 +131,22 @@ void LoadHeaders(ScopedEnv & env, jobject const params, unordered_map<string, st
static jfieldID const keyId = env->GetFieldID(g_httpHeaderClazz, "key", "Ljava/lang/String;");
static jfieldID const valueId = env->GetFieldID(g_httpHeaderClazz, "value", "Ljava/lang/String;");
- jobjectArray const headersArray =
- static_cast<jobjectArray>(env->CallObjectMethod(params, getHeaders));
+ jni::ScopedLocalRef<jobjectArray> const headersArray(
+ env.get(), static_cast<jobjectArray>(env->CallObjectMethod(params, getHeaders)));
RethrowOnJniException(env);
headers.clear();
- int const length = env->GetArrayLength(headersArray);
+ int const length = env->GetArrayLength(headersArray.get());
for (size_t i = 0; i < length; ++i)
{
- jobject headerEntry = env->GetObjectArrayElement(headersArray, i);
+ jni::ScopedLocalRef<jobject> const headerEntry(
+ env.get(), env->GetObjectArrayElement(headersArray.get(), i));
jni::ScopedLocalRef<jstring> const key(
- env.get(), static_cast<jstring>(env->GetObjectField(headerEntry, keyId)));
+ env.get(), static_cast<jstring>(env->GetObjectField(headerEntry.get(), keyId)));
jni::ScopedLocalRef<jstring> const value(
- env.get(), static_cast<jstring>(env->GetObjectField(headerEntry, valueId)));
+ env.get(), static_cast<jstring>(env->GetObjectField(headerEntry.get(), valueId)));
headers.emplace(jni::ToNativeString(env.get(), key.get()),
jni::ToNativeString(env.get(), value.get()));