sprint: fix realloc length

and make valgrind happy by memset.