only ever read or write in one iteration

either might have removed the client. whoops.
use strerror_r correctly

it might return another pointer instead of writing into the provided
buffer, apparently. thanks, valgrind.
don't access pointer values after free()

the pointer values themselves are undefined after free(), not only what
the pointees.