a_strex.c: prevent out of bound read in do_buf()