Jump to content

Bug with _ArrayDisplay (caused by wrong 2nd dim value)


Go to solution Solved by argumentum,

Recommended Posts

Posted (edited)

The piece of code causes a crash:

#include <Array.au3>
Dim $array[2][0]
_ArrayDisplay($array)

with

Quote

"C:\Program Files (x86)\AutoIt3\Include\ArrayDisplayInternals.au3" (841) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
If Not $_g_iTranspose_ArrayDisplay And $_g_aNumericSort_ArrayDisplay[$iCol] Then

Other cases are working fine, e.g.:
 

Dim $array[0][0]
Dim $array[1][0]
Dim $array[0][1]
Dim $array[0][2]
Dim $array[0][3]

 

Edited by IronFine
Posted (edited)
2 hours ago, IronFine said:
Dim $array[2][0]
2 hours ago, IronFine said:

Array variable has incorrect number of subscripts

I guess I could add a line to prevent code like that, not crash a script. Or I can ignore those that want to make a zero dimension :think:
Hey, divide by zero while you're at it :P 

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted

With an intermediate version of ArrayDisplayInternals, this blocking message was displayed :

Nothingtodisplay.png.cffc911e8c03f9b73159bc908a113374.png

But I don't use it anymore, sticking to the last official release version.

 

"I think you are searching a bug where there is no bug... don't listen to bad advice."

Posted
2 hours ago, argumentum said:

I guess I could add a line to prevent code like that, not crash a script. Or I can ignore those that want to make a zero dimension :think:
Hey, divide by zero while you're at it :P 

Not gonna do that - just noticied it while debugging and an ReDim operation set the 2nd dimension to zero.

Strange that the other case (

Dim $array[0][0]

 

Dim $array[1][0]

) are not causing that problem. Would actually expect the same behaviour in that case.

Posted
56 minutes ago, IronFine said:

Strange that the other cases are not causing that problem :
Dim $array[0][0] ; no crash
Dim $array[1][0] ; no crash
Dim $array[2][0] ; crash

I guess this is the reason why :

Func __ArrayDisplay_SortArrayStruct(Const ByRef $aArray, $iCol)
    ...
    For $i = 1 To $_g_nRows_ArrayDisplay - 1
        ...
        If Not $_g_iTranspose_ArrayDisplay And $_g_aNumericSort_ArrayDisplay[$iCol] Then ; crash line
        ...
    Next
    ...
EndFunc   ;==>__ArrayDisplay_SortArrayStruct

The crash line is found inside a For loop
* When the number of rows = [0] , the For loop is not executed (For $i = 1 To 0 - 1) ; 1 To -1
* When the number of rows = [1] , the For loop is not executed (For $i = 1 To 1 - 1) ; 1 To  0
* When the number of rows = [2] , the For loop is now executed (For $i = 1 To 2 - 1) ; 1 To  1

Because preparing a sort index on 1 column (to sort the rows) requires at least 2 rows in the array. So all row values > [2] will crash, when the column value is [0]

@jpmshould be interested with this thread, he'll decide if it requires a fix or not.

"I think you are searching a bug where there is no bug... don't listen to bad advice."

Posted

What do ReDim to less than 1 entry do ?. I guess any script, UDF or not, can be baby-proof. But again, what is the use of declaring an entry of 0 ?
 @pixelsearch, if you edit __ArrayDisplay_SortArrayStruct(), and @jpm agrees, he'll use your version :)

 @IronFine, why do you need to ReDim $aArray[2][0] ?

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted
5 minutes ago, argumentum said:

 @IronFine, why do you need to ReDim $aArray[2][0] ?

I don't need it, like I said just noticied it while debugging and an ReDim operation set the 2nd dimension to zero (zero was the result of calculation).

  • IronFine changed the title to Bug with _ArrayDisplay (caused by wrong 2nd dim value)
Posted
2 minutes ago, IronFine said:

sorry I offended you.

oh, don't make me get stated with what I take offence of !. 🤬 :P 

Actually, am not one to go for "I feel offended", as it does not attend to the matter in question.
I don't feel offended. Can, and do, feel perplexed at certain train of thoughts..., but I take no offence.

If you were to call me names, then, I'd ask what me being a "insulting word of choice" has to do with what we are discussing.

If you feel you offended me then, you are pardoned :D 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...