summaryrefslogtreecommitdiff
path: root/ext/win32ole/win32ole.c
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-23 08:39:24 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-23 08:39:24 +0000
commit5d71328bca0ebb29859d574d204d74c499030232 (patch)
tree831a1a07910b1938668fd8f461ae216649783d97 /ext/win32ole/win32ole.c
parent883c6bf7420613c690bd0e924915337b580c0bed (diff)
avoid core dump with WIN32OLE_EVENT.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/win32ole/win32ole.c')
-rw-r--r--ext/win32ole/win32ole.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index 9f756c44c4..32d92b639e 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -79,7 +79,7 @@
#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
-#define WIN32OLE_VERSION "0.6.8"
+#define WIN32OLE_VERSION "0.6.9"
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@@ -135,6 +135,7 @@ typedef struct tagIEVENTSINKOBJ {
DWORD m_dwCookie;
IConnectionPoint *pConnectionPoint;
ITypeInfo *pTypeInfo;
+ int *ptr_freed;
}IEVENTSINKOBJ, *PIEVENTSINKOBJ;
VALUE cWIN32OLE;
@@ -186,6 +187,7 @@ struct oleparamdata {
struct oleeventdata {
IEVENTSINKOBJ *pEvent;
+ int freed;
};
struct oleparam {
@@ -6253,7 +6255,9 @@ ole_search_event_at(ary, ev)
ret = i;
break;
}
- else if (rb_str_cmp(ev, event_name) == 0) {
+ else if (TYPE(ev) == T_STRING &&
+ TYPE(event_name) == T_STRING &&
+ rb_str_cmp(ev, event_name) == 0) {
ret = i;
break;
}
@@ -6399,6 +6403,7 @@ EVENTSINK_Constructor() {
pEv->m_dwCookie = 0;
pEv->pConnectionPoint = NULL;
pEv->pTypeInfo = NULL;
+ pEv->ptr_freed = NULL;
return pEv;
}
@@ -6406,6 +6411,7 @@ void EVENTSINK_Destructor(
PIEVENTSINKOBJ pEVObj
) {
if(pEVObj != NULL) {
+ *(pEVObj->ptr_freed) = 1;
free(pEVObj);
}
}
@@ -6627,6 +6633,9 @@ ole_event_free(poleev)
ITypeInfo *pti = NULL;
IConnectionPoint *pcp = NULL;
+ if (poleev->freed == 1) {
+ return;
+ }
if(poleev->pEvent) {
pti = poleev->pEvent->pTypeInfo;
if(pti) OLE_RELEASE(pti);
@@ -6737,7 +6746,8 @@ fev_initialize(argc, argv, self)
poleev->pEvent->pConnectionPoint = pConnectionPoint;
poleev->pEvent->pTypeInfo = pTypeInfo;
poleev->pEvent->m_dwCookie = dwCookie;
-
+ poleev->freed = 0;
+ poleev->pEvent->ptr_freed = &(poleev->freed);
rb_ary_push(ary_ole_event, self);
return self;
}