Jump to content
  • Advertisement
Sign in to follow this  
loboWu

array resize with negative value crash the engine.

This topic is 3242 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!