[virt-tools-list] [PATCH virt-viewer] Avoid potential memory leak in spice session

Victor Toso victortoso at redhat.com
Tue Dec 4 08:47:18 UTC 2018


On Mon, Dec 03, 2018 at 03:38:30PM -0600, Jonathon Jongsma wrote:
> If j == -1, the memory allocated for rect will leak. So move the
> allocation after the test.
> 
> Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
> ---
>  src/virt-viewer-session-spice.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
> index cb06af2..8223881 100644
> --- a/src/virt-viewer-session-spice.c
> +++ b/src/virt-viewer-session-spice.c
> @@ -1067,11 +1067,11 @@ virt_viewer_session_spice_fullscreen_auto_conf(VirtViewerSessionSpice *self)
>      displays = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free);
>  
>      for (l = initial_displays; l != NULL; l = l->next) {
> -        GdkRectangle* rect = g_new0(GdkRectangle, 1);;
>          gint j = virt_viewer_app_get_initial_monitor_for_display(app, GPOINTER_TO_INT(l->data));
>          if (j == -1)
>              continue;
>  
> +        GdkRectangle* rect = g_new0(GdkRectangle, 1);;
>          gdk_screen_get_monitor_geometry(screen, j, rect);
>          g_hash_table_insert(displays, l->data, rect);
>      }
> -- 
> 2.17.2
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20181204/9b9f4a03/attachment.sig>


More information about the virt-tools-list mailing list