[b]
...
array[i] = malloc(strlen(buffer)); <-- qui mi va sempre in errore il
...
array[i] = (char *) malloc(strlen(buffer));

ciao