hex2bin: fix access beyond string end