Fix buffer errors.

Thanks to cppcheck!