Move this line to line 146 (before beginning of the try block), then delete line 181, then this function should work correctly in all error conditions.

`amqp_destroy_connection()` calls `amqp_socket_close()` which frees the `amqp_socket_t` object, if line 175 throws, lines 181 and 182 will double-free `socket`