The order of variable assignment causing error.

Confirmed. Even on a Uno.

I suspect a bug in the String class. After all, you are doing many, many assignments of one string to another.

However under v0022 of the IDE the problem does not occur.

I presume therefore that you are using version 1.0?

@johnwasser - debug prints show it doesn't even get as far as the line you quoted before it goes bonkers.