Menu

#388 Math: "l" function has problem when array is dyn. allocated

2.0 Series
closed-fixed
Plugin (101)
5
2005-11-24
2005-07-11
No

The "l" function which returns the length of an array
shows wrongly the number of items when the array is
dynamically allocated. Whenever the number of items is
even, it increments the value by 1.

Examples (using Math Test script):

a = {}
r0 = l(a)

This returns 1. Wrong.

a = {}
a[0] = "1"
r0 = l(a)

This returns 1. Right.

a = {}
a[0] = "1"
a[1] = "2"
r0 = l(a)

This returns 3. Wrong.

...

NSIS Version: 2.07 as released (no nightly builds).

Discussion

  • Amir Szekely

    Amir Szekely - 2005-07-23

    Logged In: YES
    user_id=584402

    It might be treating the arary as a string. In this case,
    there's no null termination and that could cause the wrong
    result. I haven't looked into it yet, but it reminds me of
    this one:

    http://forums.winamp.com/showthread.php?s=&threadid=192177&highlight=null

     
  • Nobody/Anonymous

    Logged In: NO

    Nop, it still doesn't work:

    a = {}
    a[0] = "1"
    a[1] = "2"
    a[2] = 0
    r0 = l(a)

    gives the same exact "3".

     
  • Diego Pedroso

    Diego Pedroso - 2005-07-26

    Logged In: YES
    user_id=684911

    Oh, shit. I always forget to login here.

     
  • Amir Szekely

    Amir Szekely - 2005-11-24
    • assigned_to: nobody --> kichik
    • status: open --> closed-fixed
     
  • Amir Szekely

    Amir Szekely - 2005-11-24

    Logged In: YES
    user_id=584402

    Thanks, fixed.

    Currently, it makes mathtest.nsi's example #5 crash, but I'm
    working on it.

     

Log in to post a comment.