add buffer check (nul)