Ticket #5610 (closed bug: worksforme)
makeArray can cause browser crash on non array objects with length property
| Reported by: | jwheare | Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | 1.5 |
| Component: | core | Version: | 1.5 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
I haven't tested this with 1.4
For an object with a length property that casts to a non-zero positive integer, makeArray will create an array with that length filled with undefined.
>>> jQuery.makeArray({'length': '5'})
[undefined, undefined, undefined, undefined, undefined]
If the length property is zero, negative or a decimal then Firefox and Safari both hang. (FF shows the unresponsive script error, Safari hangs until it crashes)
>>> jQuery.makeArray({'length': '0'})
>>> jQuery.makeArray({'length': '5.2'})
>>> jQuery.makeArray({'length': '-3'})
Change History
comment:1 Changed 3 years ago by john
- Status changed from new to closed
- Version changed from 1.3.2 to 1.4a1
- Resolution set to fixed
comment:2 Changed 3 years ago by 314159abcde
- Status changed from closed to reopened
- Resolution fixed deleted
This has not been corrected.
Try:
jQuery.makeArray( {'length':5} );
in the firebug console on any jQuery site and it will output [undefined, undefined, undefined, undefined, undefined]
when it should return [Object { length=5}]
This is causing issues where I have an object with a length and width attribute, since it will not pass through makeArray properly.
comment:3 Changed 2 years ago by snover
- Priority changed from major to high
- Status changed from reopened to closed
- Version changed from 1.4a1 to 1.4.4
- Resolution set to worksforme
- Milestone changed from 1.4 to 1.4.5
It is working as designed.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Fixed. http://github.com/jquery/jquery/commit/715d1c5a30cc4986018bbf063713f14c34c3e258