fixed the segfault.  when using memset() I used 0 instead of \0