Fixed small problem. Original code does:

Corrected  char** ... = malloc(n * sizeof(char**)) to char** ... = malloc(n * sizeof(char*)). This is not a big issue, since I think that size of all pointers would be the same.