java: fix possible memory leak on error

Use CLEANUP_FREE to properly dispose the temporary array used for
StringList, DeviceList, FilenameList, and OStringList parameters: this
way, an early return (jumping to the ret_error label) will not forget
cleaning them up.
This commit is contained in:
Pino Toscano
2017-03-03 10:39:10 +01:00
parent 099ce1d490
commit bd55fa553f

View File

@@ -715,7 +715,7 @@ throw_out_of_memory (JNIEnv *env, const char *msg)
pr " size_t %s_size;\n" n
| StringList n | DeviceList n | FilenameList n ->
pr " size_t %s_len;\n" n;
pr " char **%s;\n" n
pr " CLEANUP_FREE char **%s = NULL;\n" n
| Bool n
| Int n ->
pr " int %s;\n" n
@@ -734,7 +734,7 @@ throw_out_of_memory (JNIEnv *env, const char *msg)
| OBool _ | OInt _ | OInt64 _ | OString _ -> ()
| OStringList n ->
pr " size_t %s_len;\n" n;
pr " char **%s;\n" n
pr " CLEANUP_FREE char **%s = NULL;\n" n
) optargs
);
@@ -857,7 +857,6 @@ throw_out_of_memory (JNIEnv *env, const char *msg)
n;
pr " (*env)->ReleaseStringUTFChars (env, o, %s[i]);\n" n;
pr " }\n";
pr " free (%s);\n" n
| Bool _
| Int _
| Int64 _
@@ -875,7 +874,6 @@ throw_out_of_memory (JNIEnv *env, const char *msg)
n;
pr " (*env)->ReleaseStringUTFChars (env, o, optargs_s.%s[i]);\n" n;
pr " }\n";
pr " free (%s);\n" n
) optargs;
pr "\n";