A hip new way to crash the IDE

Posted on Thursday 29 September 2005

Call a service method like so:


import mx.remoting.Service;

var service:Service = new Service('http://localhost/gateway.php', null, 'MyService');
var evilArray = new Array();
evilArray[0xfffffff] = true;
service.myMethod(evilArray);
 

Why does this crash the player and the IDE? Remoting serializes arrays without encoding indices; so if it encounters a very large index, it will fill the rest with an 'undefined' flag. So Flash is attempting to write approximately 200 megabytes worth of 0x06 into the stream and 'for some odd reason' it doesn't work. It actually happened to me by accident, just so you know. Which brings us to the workaround: force Flash to type as a MixedArray instead of as an array, thus sending the keys and not attempting to maintain sparsity the 'cheap way'. This can be done using a dummy index in the array, for example:


import mx.remoting.Service;

var service:Service = new Service('http://localhost/gateway.php', null, 'MyService');
var evilArray = new Array();
evilArray['evilFix'] = true;
evilArray[0xfffffff] = true;
service.myMethod(evilArray);
 

Problem solved! This is actually quite useful to know if you need to send sparse arrays over Remoting.


WordPress database error: [Can't open file: 'wp_comments.MYD'. (errno: 145)]
SELECT * FROM wp_comments WHERE comment_post_ID = '152' AND comment_approved = '1' ORDER BY comment_date

No comments have been added to this post yet.

Leave a comment




Your e-mail address is never displayed. If you run into issues with SpamKarma blocking you, email me at $patrick->5etdemi(com)


RSS feed for comments on this post | TrackBack URI