Modify

Opened 5 years ago

Last modified 4 years ago

#2884 new Bug

AutoIt tries to call COM VariantClear() on uninitialized memory

Reported by: coderpro@… 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)

comtest.zip (3.5 KB) - added by coderpro@… 5 years ago.
Connect to an MS SQL Server to test COM

Download all attachments as: .zip

Change History (2)

Changed 5 years ago by coderpro@…

Connect to an MS SQL Server to test COM

comment:1 Changed 4 years ago by mLipok

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

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.

Add Comment

Modify Ticket

Action
as new The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.