When JSON_MEMORY_MANAGE is enabled, the returned string is not-null terminated. In general, when you write StringHandler.insert(...), make sure the string being inserted is null terminated. The same problem happens in returnDecode64() as well.
I am fixing this, it also would fail in unicode mode, I'm fixing that too.
decode is not supposed to null terminate, it's binary data, not a string
I changed the documentation, to make it clearer that decode64 returns a non-terminated chunk of data
Closing this. It's been fixed, and I added a regression test. The unit testers are running now, they take about 24 hours to run, so you should be able to get the fixed version sometime tomorrow.