I believe sizeof(char) is 1 so you allocating a 1 byte string? That is just enough to hold the 0 at the end. I think this is a mistake.