array resize with negative value crash the engine.

Started by
4 comments, last by loboWu 14 years, 5 months ago
void main() { uint8[] recv(10); recv.resize(-1); } resize() method of array only allow unsigned int parameter. so this statement will implicit convert to 0xFFFFFFFF which is too large, and crash the engine. I suggest change the resize() parameter to signed int. Thanks. Lobo
Advertisement
I'm not even familiar with the AngelCode system, but why do you need over 4GB of space in an array (8bytes x 0xFFFFFFFF), and what do you expect resizing it to a negative value to actually do? I'm just curious about this one.
---------------------------Visit my Blog at http://robwalkerdme.blogspot.com
I use angelscript + registered C functions to develope a SDK enviroment.
Twenty developer use this SDK.

In many situation, resize will be called in rutime.
But as you know, developer always make a mistake,
resize(-1) is not the most stupid mistake.

I do my best to prevent Crash in SDK level(registered C functions).
But the resize(-1) raise a script VM exception, which I couldn't catch it.

In a short word, resize(-1) make my SDK shakily.
Thanks for the tip. This has definitely got to be fixed, though making the argument signed is not the way to do it, as you can still pass a very large positive integer and get the same result.

I assume the crash is due to the failure to allocate the memory so I'll add some validations for this to make sure it doesn't crash anything.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I've fixed this now. The problem wasn't the memory allocation, but rather the overflow of the 32bit word when determining the buffer size.

You can get the fix in the SVN, revision 500.

Remember, that this situation is still an error so the script will throw a script exception, which will abort the script. It will not crash the application though.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

thank you.

This topic is closed to new replies.

Advertisement