memcached: handle error cases and alloc enough for null termination