fix a potential data overflow bug