Fix possible dereference on last file character

Not the cause of the problem I figure, but safer anyway.

Can you run on MSVC and see if the problem is there with this anyway?
I'll look into the other location as well.