Opened 3 months ago
Last modified 3 months ago
#4027 new Feature Request
ObjCreateInterface crashes when 3rd param is absent or Default (yet works with the empty string '')
Reported by: | anonymous | Owned by: | |
---|---|---|---|
Milestone: | Component: | AutoIt | |
Version: | Severity: | None | |
Keywords: | Cc: |
Description
in all versions from 3.3.15.1 up. in earier version incl. 3.3.15.0, it sets @error to 1(in 3.3.15.0) or 2048(in 3.3.14.*)
It's nary an inconvenience, but still a bug is a bug.
The fix should be trivial, it's only has to check if the 3rd param is not_given/Default/Null, and threat such cases the same as it treats the empty string, which works as *intuitively* would be expected (yet the documentation tells us to use Default if we want to use only the IUnknown's standard methods(QueryInterface,AddRef,Release), yet in fact it's the empty string that does it, which is sensible but the documentation should be updated after the fix to say so explicitly.)
discovered it while tinkering with GUIRichEdit.au3's __RichCom_Object_GetNewStorage.
here's the updated version -- it's simply a bit clearer:
Func __RichCom_Object_GetNewStorage($pObject, $pPstg) #forceref $pObject Local $aRet = DllCall($__g_hLib_RichCom_OLE32, "dword", "CreateILockBytesOnHGlobal", "hwnd", 0, "bool", True, "ptr*", 0) If NOT $aRet[0] Then Local $pLockBytes = $aRet[3] $aRet = DllCall($__g_hLib_RichCom_OLE32, "dword", "StgCreateDocfileOnILockBytes", "ptr", $pLockBytes, "dword", BitOR(0x10, 2, 0x1000), "dword", 0, "ptr*", 0) ; --- BitOR(STGM_SHARE_EXCLUSIVE(=0x10), STGM_READWRITE(=2), STGM_CREATE(=0x1000)) DllStructSetData(DllStructCreate("ptr", $pPstg), 1, $aRet[4]) ; if there's an error, call IUnknown.Release on $pLockBytes If $aRet[0] Then (ObjCreateInterface($pLockBytes,'{00000000-0000-0000-C000-000000000046}', '').Release()) ; will crash sans parentheses - ticket #4026 EndIf Return $aRet[0] ;error code EndFunc ;==>__RichCom_Object_GetNewStorage
Attachments (0)
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
Automatic ticket cleanup.