Archive: Long string error handling?


Long string error handling?
Just wondering what people think about the way long strings are handled. First off, I have not looked extensively to see if it is already a feature. I tried searching, but found nothing on the first 3 pages of results. Its to do with Path Manipulation specifically, but something that could be needed generally.

I've just spent a good while (a few hours) trying to figure out why an installer I wrote was totally trashing a small amount of Path environment variables on client machines. It would simply say the Path variable was empty, and then overwrite it with the directory I wanted. It took me ages to discover that is was simply the path variable on his/her computer being longer than 1024 characters. On a development machine, this length can easily be exceeded. I'm only 50 characters under this limit myself.

This is dangerous on so many levels!

Is it possible to have the installer totally bomb out when this happens? Trying to reconstruct path environment variables takes forever when you have numerous SDK's and build environments etc.

I really do consider this a huge flaw in the way nsis does this. There should be some sort of way to handle a string overflowing, even if it does totally stop the installer. An installer should never trash a machine, if in doubt - don't install.

I'm now using the long string build of makensis which is working nicely, but I do think string error handling could be good.


Use the 8192 string length special build:
http://nsis.sf.net/Special_Builds

Stu


there is no built in checking, but you can check the string length yourself before you write the env strings


Originally posted by Afrow UK
Use the 8192 string length special build:
http://nsis.sf.net/Special_Builds

Stu
Already am, see bottom of post.


How can you check the length of a string, if the returned value is nil because its too long? :D

If you want to be have protection against this then the best way to go is to write an executable or call a dll that does it which will allocate memory as required.

Stu