fix possible buffer overrun asserts
Merge pull request #3597 from ZappoMan/fixcrash

fix possible buffer overrun asserts