Fix crash caused by buffer overrun

Sorry title is incorrect. It's a read overrun. So if you are using memory checker type tools it's going to cause a crash.