Connection to mpd is no longer left open when invalid input received. Segmentation fault was a result of passing getline an uninitialized pointer. Also make sure to free the pointer after.