Modify ↓
Opened 11 years ago
Closed 6 years ago
#2884 closed Bug (Wont Fix)
AutoIt tries to call COM VariantClear() on uninitialized memory
| Reported by: | Owned by: | ||
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | 3.3.13.19 | Severity: | None |
| Keywords: | COM crash | Cc: |
Description
A COM OLE query to an MS SQL Server database results in a crash in AutoIt's wrapper that calls oleaut32.dll VariantClear(). The attached file recreates the bug.
Attachments (1)
Change History (3)
by , 11 years ago
| Attachment: | comtest.zip added |
|---|
comment:1 by , 11 years ago
this is the same problem like here:
https://www.autoitscript.com/trac/autoit/ticket/2887
As you can see here:
Func _ExecStatements(Const $oConn, Const $sStatements, Const $bIgnoreInvalidObjRef = False)
_WriteDiag("Info", "Executing: "&@CRLF&$sStatements)
$COMstatusMessage = "attempting to execute query"
If $bIgnoreInvalidObjRef Then
$g_oErrObj = ObjEvent("AutoIt.Error", "_COMwarningHandlerWrapper")
EndIf
Local $oRecordSet = _SQLQuery($oConn, $sStatements)
If $bIgnoreInvalidObjRef Then
$g_oErrObj = ObjEvent("AutoIt.Error", "_COMerrorHandler")
EndIf
Return $oRecordSet
EndFunc
You are setting $g_oErrObj few times.
The workaround is to set:
$g_oErrObj = Null
Func _ExecStatements(Const $oConn, Const $sStatements, Const $bIgnoreInvalidObjRef = False)
_WriteDiag("Info", "Executing: "&@CRLF&$sStatements)
$COMstatusMessage = "attempting to execute query"
If $bIgnoreInvalidObjRef Then
$g_oErrObj = Null
$g_oErrObj = ObjEvent("AutoIt.Error", "_COMwarningHandlerWrapper")
EndIf
Local $oRecordSet = _SQLQuery($oConn, $sStatements)
If $bIgnoreInvalidObjRef Then
$g_oErrObj = Null
$g_oErrObj = ObjEvent("AutoIt.Error", "_COMerrorHandler")
EndIf
Return $oRecordSet
EndFunc
Note:
See TracTickets
for help on using tickets.

Connect to an MS SQL Server to test COM