Opened 11 years ago

Closed 9 years ago

Last modified 9 years ago

#1551 closed Bug (Fixed)

Crash the script when changing array

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


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 Changed 11 years ago by MrCreatoR <mscreator@…>

Confirmed, few tests on several autoit versions:

; Crashes in: / / /
; Not crashes in: / /
Dim $Arr[1]
$Arr[0] = _Test()

Func _Test()
    $Arr = ''


; Crashes in: / / / / /
; Not crashes in:
Dim $Arr[1]
$Arr[0] = _Test('Test')

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

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

comment:2 Changed 11 years ago by MrCreatoR <mscreator@…>

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 Changed 11 years ago by Jpm

  • Owner set to Jon
  • Status changed from new to assigned

comment:4 Changed 9 years ago by trancexx

  • Milestone set to
  • Owner changed from Jon to trancexx
  • Resolution set to Fixed
  • Status changed from assigned to closed

Fixed by revision [6886] in version:

comment:5 Changed 9 years ago by BrewManNH

If I run this code using AutoIt 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:(\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", "")


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

comment:6 Changed 9 years ago by anonymous

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

comment:7 Changed 9 years ago by Valik

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

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

as closed The owner will remain trancexx.

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

Note: See TracTickets for help on using tickets.