[Spice-devel] [spice-server PATCH 2/4] dcc_gl_scanout_item_new: allocate item when needed

Uri Lublin uril at redhat.com
Wed Sep 14 12:31:00 UTC 2016


Prevents a leak on early return.

Found by coverity.

Signed-off-by: Uri Lublin <uril at redhat.com>
---
 server/dcc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/server/dcc.c b/server/dcc.c
index 1a7aac9..cdd888b 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -571,7 +571,7 @@ static RedSurfaceDestroyItem *red_surface_destroy_item_new(RedChannel *channel,
 
 RedPipeItem *dcc_gl_scanout_item_new(RedChannelClient *rcc, void *data, int num)
 {
-    RedGlScanoutUnixItem *item = spice_new(RedGlScanoutUnixItem, 1);
+    RedGlScanoutUnixItem *item;
 
     /* FIXME: on !unix peer, start streaming with a video codec */
     if (!reds_stream_is_plain_unix(red_channel_client_get_stream(rcc)) ||
@@ -581,6 +581,7 @@ RedPipeItem *dcc_gl_scanout_item_new(RedChannelClient *rcc, void *data, int num)
         return NULL;
     }
 
+    item = spice_new(RedGlScanoutUnixItem, 1);
     red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_GL_SCANOUT);
 
     return &item->base;
-- 
2.7.4



More information about the Spice-devel mailing list