@sscalpone I've mostly added this for discussion; I don't think there's another way of doing this with the way we currently handle newlines but I also don't think doing this is the best way forward. We might want to merge it to fix the bug in the short term while we look at newline handling though.
Well, currently this will crash if there isn't enough free memory with an error in the MemoryBuffer code. What other sensible behaviour is there? We can't continue if there's no memory as we'll have an infinite loop in the parser so crashing out seems the only option?