From 36c5cd4fb7f900f6881a05edb3426401321a6f56 Mon Sep 17 00:00:00 2001 From: clay_shooter Date: Mon, 20 Feb 2006 14:04:46 +0000 Subject: [PATCH] 1224219 fixed incorrect memory release --- jni/SafeArray.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/jni/SafeArray.cpp b/jni/SafeArray.cpp index 661df53..9dc0b93 100644 --- a/jni/SafeArray.cpp +++ b/jni/SafeArray.cpp @@ -558,7 +558,9 @@ JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromStringArray V_VT(&v) = VT_BSTR; for(int i=0;iGetObjectArrayElement(a, i); - // jacob report 1224219 should use unicode and not UTF-8 (Variant modified in previous report + // jacob report 1224219 should use unicode and not UTF-8 + // GetStringUTFChars() replaced with GetStringChars() + // (Variant modified in previous report) const jchar *str = env->GetStringChars(s, NULL); CComBSTR bs(str); V_VT(&v) = VT_BSTR; @@ -571,7 +573,9 @@ JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromStringArray } else if (vt == VT_BSTR) { for(int i=0;iGetObjectArrayElement(a, i); - // jacob report 1224219 should use unicode and not UTF-8 (Variant modified in previous report + // jacob report 1224219 should use unicode and not UTF-8 + // GetStringUTFChars() replaced with GetStringChars() + // (Variant modified in previous report) const jchar *str = env->GetStringChars(s, NULL); CComBSTR bs(str); BSTR bstr = bs.Detach(); @@ -1625,7 +1629,7 @@ JNIEXPORT jstring JNICALL Java_com_jacob_com_SafeArray_getString__I jstring js = env->NewString(bs, SysStringLen(bs)); // jacob report 1224219 // SafeArrayGetElement memory must be freed http://www.canaimasoft.com/f90VB/OnlineManuals/Reference/TH_31.htm - if (bs) free(bs); + if (bs) SysFreeString(bs); return js; } ThrowComFail(env, "safearray cannot get string", 0);