Modify

Opened 16 years ago

Closed 14 years ago

Last modified 14 years ago

#1551 closed Bug (Fixed)

Crash the script when changing array

Reported by: Yashied Owned by: trancexx
Milestone: 3.3.9.3 Component: AutoIt
Version: 3.3.6.0 Severity: None
Keywords: Cc:

Description

AutoIt crashes the script instead indicate an error ("Subscript used with non-Array variable.") in the following code.

Global $aArray[1]

$aArray[0] = _MyFunc('Test')

Func _MyFunc($sStr)
;	Local $aArray
	$aArray = $sStr
	Return $aArray
EndFunc   ;==>_MyFunc

Attachments (0)

Change History (7)

comment:1 by MrCreatoR <mscreator@…>, 16 years ago

Confirmed, few tests on several autoit versions:

; Crashes in: 3.3.0.0 / 3.3.2.0 / 3.3.4.0 / 3.3.6.0
; Not crashes in: 3.2.8.1 / 3.2.10.0 / 3.2.12.0
Dim $Arr[1]
$Arr[0] = _Test()

Func _Test()
    $Arr = ''
EndFunc

;========================================================================

; Crashes in: 3.2.8.1 /  3.2.10.0 / 3.3.0.0 / 3.3.2.0 / 3.3.4.0 / 3.3.6.0
; Not crashes in: 3.2.12.0
Dim $Arr[1]
$Arr[0] = _Test('Test')

Func _Test($vVar)
    $Arr = $vVar
    Return $Arr
EndFunc

AutoIt:(see above) (Os:WIN_XP/X86/Service Pack 3 Language:0419 Keyboard:00000409 Cpu:X64)

comment:2 by MrCreatoR <mscreator@…>, 16 years ago

One more update...

Here is the quickest example that reproduces this crash:

Dim $Arr[1]
$Arr[0] = Assign("Arr", "") ;Replace here "" with 0, and the script is not crashed o_O

comment:3 by J-Paul Mesnage, 16 years ago

Owner: set to Jon
Status: newassigned

comment:4 by trancexx, 14 years ago

Milestone: 3.3.9.3
Owner: changed from Jon to trancexx
Resolution: Fixed
Status: assignedclosed

Fixed by revision [6886] in version: 3.3.9.3

comment:5 by BrewManNH, 14 years ago

If I run this code using AutoIt 3.3.9.5 I am still getting an error message

Dim $Arr[1]
$Arr[0] = Assign("Arr", "") ;Replace here "" with 0, and the script is not crashed o_O


Running:(3.3.9.5):F:\PortableAutoIt3.3.8\App\beta\autoit3_x64.exe "\test.au3"
"\test.au3" (16) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$Arr[0] = Assign("Arr", "")

ERROR

I've tried it with both the x86 and x64 versions, same error message.

If I run this code, I don't get an error message, but the Global $Arr has been turned into a simple variable and not an array.

Dim $Arr[1]
$Arr[0] = _Test('Test')
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Arr = ' & $Arr & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

Func _Test($vVar)
    $Arr = $vVar
    Return $Arr
EndFunc

comment:6 by anonymous, 14 years ago

Update, the second code runs in 3.3.8.0, but not in 3.3.9.5, that still gives me the same error message.

comment:7 by Valik, 14 years ago

Previously it crashed, now it gives a user-friendly error. An error message is the correct behavior. The code is stupid. Write better code.

Modify Ticket

Action
as closed The owner will remain trancexx.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.