|
|
ecdf9b |
From d5e114ae636089ff6c1554c1d98b1ea8d8ad3ff3 Mon Sep 17 00:00:00 2001
|
|
|
ecdf9b |
From: Hans de Goede <hdegoede@redhat.com>
|
|
|
ecdf9b |
Date: Mon, 10 Jun 2013 13:44:47 +0200
|
|
|
ecdf9b |
Subject: [PATCH 09/35] cheese-camera-device: Fix memleak in get_best_format
|
|
|
ecdf9b |
|
|
|
ecdf9b |
cheese_camera_device_get_best_format() calls
|
|
|
ecdf9b |
cheese_camera_device_get_format_list(), which returns a sorted copy of the
|
|
|
ecdf9b |
format lists, then takes the first element of that list, and returns a
|
|
|
ecdf9b |
copy of that element. While never freeing the list copy.
|
|
|
ecdf9b |
|
|
|
ecdf9b |
This patch fixes this leak by simply making the priv->formats list sorted
|
|
|
ecdf9b |
so that cheese_camera_device_get_best_format can use it directly without
|
|
|
ecdf9b |
the need to make (and then later free) a copy.
|
|
|
ecdf9b |
|
|
|
ecdf9b |
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
|
ecdf9b |
---
|
|
|
ecdf9b |
libcheese/cheese-camera-device.c | 7 +++----
|
|
|
ecdf9b |
1 file changed, 3 insertions(+), 4 deletions(-)
|
|
|
ecdf9b |
|
|
|
ecdf9b |
diff --git a/libcheese/cheese-camera-device.c b/libcheese/cheese-camera-device.c
|
|
|
ecdf9b |
index c7b7a07..e5ec5fa 100644
|
|
|
ecdf9b |
--- a/libcheese/cheese-camera-device.c
|
|
|
ecdf9b |
+++ b/libcheese/cheese-camera-device.c
|
|
|
ecdf9b |
@@ -219,7 +219,7 @@ cheese_camera_device_add_format (CheeseCameraDevice *device, CheeseVideoFormat *
|
|
|
ecdf9b |
|
|
|
ecdf9b |
GST_INFO ("%dx%d", format->width, format->height);
|
|
|
ecdf9b |
|
|
|
ecdf9b |
- priv->formats = g_list_append (priv->formats, format);
|
|
|
ecdf9b |
+ priv->formats = g_list_insert_sorted (priv->formats, format, compare_formats);
|
|
|
ecdf9b |
}
|
|
|
ecdf9b |
|
|
|
ecdf9b |
/*
|
|
|
ecdf9b |
@@ -700,7 +700,7 @@ cheese_camera_device_get_format_list (CheeseCameraDevice *device)
|
|
|
ecdf9b |
{
|
|
|
ecdf9b |
g_return_val_if_fail (CHEESE_IS_CAMERA_DEVICE (device), NULL);
|
|
|
ecdf9b |
|
|
|
ecdf9b |
- return g_list_sort (g_list_copy (device->priv->formats), compare_formats);
|
|
|
ecdf9b |
+ return g_list_copy (device->priv->formats);
|
|
|
ecdf9b |
}
|
|
|
ecdf9b |
|
|
|
ecdf9b |
/**
|
|
|
ecdf9b |
@@ -788,8 +788,7 @@ cheese_camera_device_get_best_format (CheeseCameraDevice *device)
|
|
|
ecdf9b |
|
|
|
ecdf9b |
g_return_val_if_fail (CHEESE_IS_CAMERA_DEVICE (device), NULL);
|
|
|
ecdf9b |
|
|
|
ecdf9b |
- format = g_boxed_copy (CHEESE_TYPE_VIDEO_FORMAT,
|
|
|
ecdf9b |
- cheese_camera_device_get_format_list (device)->data);
|
|
|
ecdf9b |
+ format = g_boxed_copy (CHEESE_TYPE_VIDEO_FORMAT, device->priv->formats->data);
|
|
|
ecdf9b |
|
|
|
ecdf9b |
GST_INFO ("%dx%d", format->width, format->height);
|
|
|
ecdf9b |
return format;
|
|
|
ecdf9b |
--
|
|
|
ecdf9b |
1.8.2.1
|
|
|
ecdf9b |
|