[libbluray-devel] Fixed leak in _load_jvm_win32()

hpi1 git at videolan.org
Wed Jan 22 12:49:42 CET 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Jan 21 20:53:15 2014 +0200| [1c58348d50cebe142ead67a74e91cfff717e169b] | committer: hpi1

Fixed leak in _load_jvm_win32()

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=1c58348d50cebe142ead67a74e91cfff717e169b
---

 src/libbluray/bdj/bdj.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/libbluray/bdj/bdj.c b/src/libbluray/bdj/bdj.c
index bf77d68..55d2dad 100644
--- a/src/libbluray/bdj/bdj.c
+++ b/src/libbluray/bdj/bdj.c
@@ -52,7 +52,7 @@ typedef jint (JNICALL * fptr_JNI_CreateJavaVM) (JavaVM **pvm, void **penv,void *
 #if defined(_WIN32) && !defined(HAVE_BDJ_J2ME)
 static void *_load_jvm_win32(const char **p_java_home)
 {
-    static const char *java_home = NULL;
+    static const char java_home[256] = "";
 
     wchar_t buf_loc[4096] = L"SOFTWARE\\JavaSoft\\Java Runtime Environment\\";
     wchar_t buf_vers[128];
@@ -94,9 +94,9 @@ static void *_load_jvm_win32(const char **p_java_home)
 
     if (r == ERROR_SUCCESS) {
         /* do not fail even if not found */
-        WideCharToMultiByte(CP_UTF8, 0, buf_loc, -1, strbuf, sizeof(strbuf), NULL, NULL);
-        *p_java_home = java_home = str_dup(strbuf);
-        BD_DEBUG(DBG_BDJ, "JavaHome: %s\n", strbuf);
+        WideCharToMultiByte(CP_UTF8, 0, buf_loc, -1, java_home, sizeof(java_home), NULL, NULL);
+        *p_java_home = java_home;
+        BD_DEBUG(DBG_BDJ, "JavaHome: %s\n", java_home);
     }
 
     dSize = sizeof(buf_loc);



More information about the libbluray-devel mailing list