mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/win32ole/win32ole.c(ole_invoke): fix memory leak.
[ruby-bugs-20792] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ac531a8aa8
commit
238738f314
2 changed files with 25 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Jun 24 22:09:18 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||||
|
|
||||||
|
* ext/win32ole/win32ole.c(ole_invoke): fix memory leak.
|
||||||
|
[ruby-bugs-20792]
|
||||||
|
|
||||||
Tue Jun 24 17:20:39 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Tue Jun 24 17:20:39 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* configure.in (rb_cv_fork_with_pthread): check after check for
|
* configure.in (rb_cv_fork_with_pthread): check after check for
|
||||||
|
|
|
@ -116,7 +116,7 @@
|
||||||
|
|
||||||
#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
|
#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
|
||||||
|
|
||||||
#define WIN32OLE_VERSION "1.1.4"
|
#define WIN32OLE_VERSION "1.1.5"
|
||||||
|
|
||||||
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
|
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
|
||||||
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
|
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
|
||||||
|
@ -264,6 +264,7 @@ static UINT ole_encoding2cp(rb_encoding *enc);
|
||||||
static UINT ole_init_cp();
|
static UINT ole_init_cp();
|
||||||
static char *ole_wc2mb(LPWSTR pw);
|
static char *ole_wc2mb(LPWSTR pw);
|
||||||
static VALUE ole_hresult2msg(HRESULT hr);
|
static VALUE ole_hresult2msg(HRESULT hr);
|
||||||
|
static void ole_freeexceptinfo(EXCEPINFO *pExInfo);
|
||||||
static VALUE ole_excepinfo2msg(EXCEPINFO *pExInfo);
|
static VALUE ole_excepinfo2msg(EXCEPINFO *pExInfo);
|
||||||
static void ole_raise(HRESULT hr, VALUE ecs, const char *fmt, ...);
|
static void ole_raise(HRESULT hr, VALUE ecs, const char *fmt, ...);
|
||||||
static void ole_initialize();
|
static void ole_initialize();
|
||||||
|
@ -963,6 +964,14 @@ ole_hresult2msg(HRESULT hr)
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ole_freeexceptinfo(EXCEPINFO *pExInfo)
|
||||||
|
{
|
||||||
|
SysFreeString(pExInfo->bstrDescription);
|
||||||
|
SysFreeString(pExInfo->bstrSource);
|
||||||
|
SysFreeString(pExInfo->bstrHelpFile);
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
ole_excepinfo2msg(EXCEPINFO *pExInfo)
|
ole_excepinfo2msg(EXCEPINFO *pExInfo)
|
||||||
{
|
{
|
||||||
|
@ -1001,9 +1010,7 @@ ole_excepinfo2msg(EXCEPINFO *pExInfo)
|
||||||
}
|
}
|
||||||
if(pSource) free(pSource);
|
if(pSource) free(pSource);
|
||||||
if(pDescription) free(pDescription);
|
if(pDescription) free(pDescription);
|
||||||
SysFreeString(pExInfo->bstrDescription);
|
ole_freeexceptinfo(pExInfo);
|
||||||
SysFreeString(pExInfo->bstrSource);
|
|
||||||
SysFreeString(pExInfo->bstrHelpFile);
|
|
||||||
return error_msg;
|
return error_msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3167,6 +3174,9 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
|
||||||
param = rb_ary_entry(paramS, i-cNamedArgs);
|
param = rb_ary_entry(paramS, i-cNamedArgs);
|
||||||
ole_val2variant(param, &op.dp.rgvarg[n]);
|
ole_val2variant(param, &op.dp.rgvarg[n]);
|
||||||
}
|
}
|
||||||
|
if (hr == DISP_E_EXCEPTION) {
|
||||||
|
ole_freeexceptinfo(&excepinfo);
|
||||||
|
}
|
||||||
memset(&excepinfo, 0, sizeof(EXCEPINFO));
|
memset(&excepinfo, 0, sizeof(EXCEPINFO));
|
||||||
VariantInit(&result);
|
VariantInit(&result);
|
||||||
hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
|
hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
|
||||||
|
@ -3179,6 +3189,9 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
|
||||||
* hResult == DISP_E_EXCEPTION. this only happens on
|
* hResult == DISP_E_EXCEPTION. this only happens on
|
||||||
* functions whose DISPID > 0x8000 */
|
* functions whose DISPID > 0x8000 */
|
||||||
if ((hr == DISP_E_EXCEPTION || hr == DISP_E_MEMBERNOTFOUND) && DispID > 0x8000) {
|
if ((hr == DISP_E_EXCEPTION || hr == DISP_E_MEMBERNOTFOUND) && DispID > 0x8000) {
|
||||||
|
if (hr == DISP_E_EXCEPTION) {
|
||||||
|
ole_freeexceptinfo(&excepinfo);
|
||||||
|
}
|
||||||
memset(&excepinfo, 0, sizeof(EXCEPINFO));
|
memset(&excepinfo, 0, sizeof(EXCEPINFO));
|
||||||
hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
|
hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
|
||||||
&IID_NULL, lcid, wFlags,
|
&IID_NULL, lcid, wFlags,
|
||||||
|
@ -3200,6 +3213,9 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
|
||||||
param = rb_ary_entry(paramS, i-cNamedArgs);
|
param = rb_ary_entry(paramS, i-cNamedArgs);
|
||||||
ole_val2variant2(param, &op.dp.rgvarg[n]);
|
ole_val2variant2(param, &op.dp.rgvarg[n]);
|
||||||
}
|
}
|
||||||
|
if (hr == DISP_E_EXCEPTION) {
|
||||||
|
ole_freeexceptinfo(&excepinfo);
|
||||||
|
}
|
||||||
memset(&excepinfo, 0, sizeof(EXCEPINFO));
|
memset(&excepinfo, 0, sizeof(EXCEPINFO));
|
||||||
VariantInit(&result);
|
VariantInit(&result);
|
||||||
hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
|
hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
|
||||||
|
|
Loading…
Add table
Reference in a new issue