[Spice-devel] [PATCH spice-server 1/4] Clear "msg" pointers after releasing

Frediano Ziglio fziglio at redhat.com
Mon Feb 13 11:03:16 UTC 2017


Avoid possible dandling pointers.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/red-channel-client.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 06fb8a8..2450923 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -1133,6 +1133,7 @@ static void red_peer_handle_incoming(RedsStream *stream, IncomingHandler *handle
                                           msg_size - handler->msg_pos);
             if (bytes_read == -1) {
                 handler->cb->release_msg_buf(handler->opaque, msg_type, msg_size, handler->msg);
+                handler->msg = NULL;
                 handler->cb->on_error(handler->opaque);
                 return;
             }
@@ -1154,6 +1155,7 @@ static void red_peer_handle_incoming(RedsStream *stream, IncomingHandler *handle
             if (parsed == NULL) {
                 spice_printerr("failed to parse message type %d", msg_type);
                 handler->cb->release_msg_buf(handler->opaque, msg_type, msg_size, handler->msg);
+                handler->msg = NULL;
                 handler->cb->on_error(handler->opaque);
                 return;
             }
-- 
2.9.3



More information about the Spice-devel mailing list