Fix buffer overruns
Merge pull request #2038 from sjinks/1.3.0

[URGENT] Fix buffer overruns