adb: use delete on objects with destructors.
asocket has a destructor now, so we have to delete it, or leak the
data pointed to by its std::string.
Bug: http://b/73257049
Test: manual testing with asan
Change-Id: Ia88199292cc74e10032a9a16226d3afc61c3e0be
diff --git a/socket.h b/socket.h
index a1b52b3..34915b6 100644
--- a/socket.h
+++ b/socket.h
@@ -36,31 +36,31 @@
struct asocket {
/* the unique identifier for this asocket
*/
- unsigned id;
+ unsigned id = 0;
/* flag: set when the socket's peer has closed
* but packets are still queued for delivery
*/
- int closing;
+ int closing = 0;
// flag: set when the socket failed to write, so the socket will not wait to
// write packets and close directly.
- bool has_write_error;
+ bool has_write_error = 0;
/* flag: quit adbd when both ends close the
* local service socket
*/
- int exit_on_close;
+ int exit_on_close = 0;
// the asocket we are connected to
- asocket* peer;
+ asocket* peer = nullptr;
/* For local asockets, the fde is used to bind
* us to our fd event system. For remote asockets
* these fields are not used.
*/
- fdevent fde;
- int fd;
+ fdevent fde = {0};
+ int fd = 0;
// queue of data waiting to be written
std::deque<Range> packet_queue;
@@ -73,27 +73,27 @@
* peer->ready() when we once again are ready to
* receive data.
*/
- int (*enqueue)(asocket* s, std::string data);
+ int (*enqueue)(asocket* s, std::string data) = nullptr;
/* ready is called by the peer when it is ready for
* us to send data via enqueue again
*/
- void (*ready)(asocket* s);
+ void (*ready)(asocket* s) = nullptr;
/* shutdown is called by the peer before it goes away.
* the socket should not do any further calls on its peer.
* Always followed by a call to close. Optional, i.e. can be NULL.
*/
- void (*shutdown)(asocket* s);
+ void (*shutdown)(asocket* s) = nullptr;
/* close is called by the peer when it has gone away.
* we are not allowed to make any further calls on the
* peer once our close method is called.
*/
- void (*close)(asocket* s);
+ void (*close)(asocket* s) = nullptr;
/* A socket is bound to atransport */
- atransport* transport;
+ atransport* transport = nullptr;
size_t get_max_payload() const;
};