you want strlen + 1 here, to capture the null terminator, no?