Fix memory leaks with read & write

All read & write functions failed to free their received packets on
success. This leaked ~512 bytes per request, so that was pretty bad.
Thanks valgrind!