fix possible buffer overwrite spotted by Bert Belder