If you have hard to find crashes using this code, this is probably why: char *read_server(int client) { // read data from the client char input[1024] = { 0 }; ...... return input; }