summaryrefslogtreecommitdiff
path: root/ext/win32ole/win32ole.c
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-19 04:46:51 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-19 04:46:51 +0000
commitf8c300e06394b21c82a0e976a56e0322870955ee (patch)
tree97daae68e94ef8e92504894616fe8fdd21eb2a4a /ext/win32ole/win32ole.c
parent524ad518b67a20445980de24b85b7d8b4d4fc2e9 (diff)
avoid core dump with WIN32OLE_EVENT. [ruby-dev:27133]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9223 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/win32ole/win32ole.c')
-rw-r--r--ext/win32ole/win32ole.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index a463d3ccc7..8d13f006c3 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -78,7 +78,7 @@
#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
-#define WIN32OLE_VERSION "0.6.4"
+#define WIN32OLE_VERSION "0.6.5"
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@@ -134,6 +134,7 @@ typedef struct tagIEVENTSINKOBJ {
DWORD m_dwCookie;
IConnectionPoint *pConnectionPoint;
ITypeInfo *pTypeInfo;
+ int *ptr_freed;
}IEVENTSINKOBJ, *PIEVENTSINKOBJ;
VALUE cWIN32OLE;
@@ -183,6 +184,7 @@ struct oleparamdata {
struct oleeventdata {
IEVENTSINKOBJ *pEvent;
+ int freed;
};
struct oleparam {
@@ -5095,6 +5097,7 @@ EVENTSINK_Constructor() {
pEv->m_dwCookie = 0;
pEv->pConnectionPoint = NULL;
pEv->pTypeInfo = NULL;
+ pEv->ptr_freed = NULL;
return pEv;
}
@@ -5102,6 +5105,7 @@ void EVENTSINK_Destructor(
PIEVENTSINKOBJ pEVObj
) {
if(pEVObj != NULL) {
+ *(pEVObj->ptr_freed) = 1;
free(pEVObj);
}
}
@@ -5323,6 +5327,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);
@@ -5362,7 +5369,7 @@ fev_initialize(argc, argv, self)
IConnectionPointContainer *pContainer;
IConnectionPoint *pConnectionPoint;
IEVENTSINKOBJ *pIEV;
- DWORD dwCookie;
+ DWORD dwCookie = 0;
struct oleeventdata *poleev;
rb_secure(4);
@@ -5423,7 +5430,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;
}