From: Florian Forster Date: Fri, 19 Jun 2015 08:54:02 +0000 (+0200) Subject: java plugin: Fix memory leak. X-Git-Tag: collectd-5.5.1~68^2~28 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=d23d1b50743537d195976a45620bb069b3c3efed;p=collectd.git java plugin: Fix memory leak. --- diff --git a/src/java.c b/src/java.c index 10d837e6..ee14373e 100644 --- a/src/java.c +++ b/src/java.c @@ -1790,6 +1790,7 @@ static cjni_callback_info_t *cjni_callback_info_create (JNIEnv *jvm_env, /* {{{ pthread_mutex_unlock (&java_callbacks_lock); ERROR ("java plugin: cjni_callback_info_create: strdup failed."); (*jvm_env)->ReleaseStringUTFChars (jvm_env, o_name, c_name); + sfree (cbi); return (NULL); } @@ -1799,7 +1800,8 @@ static cjni_callback_info_t *cjni_callback_info_create (JNIEnv *jvm_env, /* {{{ if (cbi->object == NULL) { ERROR ("java plugin: cjni_callback_info_create: NewGlobalRef failed."); - free (cbi); + sfree (cbi->name); + sfree (cbi); return (NULL); } @@ -1807,7 +1809,9 @@ static cjni_callback_info_t *cjni_callback_info_create (JNIEnv *jvm_env, /* {{{ if (cbi->class == NULL) { ERROR ("java plugin: cjni_callback_info_create: GetObjectClass failed."); - free (cbi); + (*jvm_env)->DeleteGlobalRef (jvm_env, cbi->object); + sfree (cbi->name); + sfree (cbi); return (NULL); } @@ -1818,7 +1822,9 @@ static cjni_callback_info_t *cjni_callback_info_create (JNIEnv *jvm_env, /* {{{ ERROR ("java plugin: cjni_callback_info_create: " "Cannot find the `%s' method with signature `%s'.", method_name, method_signature); - free (cbi); + (*jvm_env)->DeleteGlobalRef (jvm_env, cbi->object); + sfree (cbi->name); + sfree (cbi); return (NULL); }