mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 14:56:36 +00:00
gl: Don't leak temp strings in _RGB_pixel_order()
Fix a memory leak of temporary strings when computing swizzling of RGB formats.
This commit is contained in:
parent
5007311198
commit
0f6b04c91d
1 changed files with 11 additions and 8 deletions
|
@ -829,7 +829,9 @@ _RGB_pixel_order (const gchar * expected, const gchar * wanted)
|
|||
{
|
||||
GString *ret = g_string_sized_new (4);
|
||||
gchar *expect, *want;
|
||||
gchar *orig_want;
|
||||
int len;
|
||||
gboolean discard_output = TRUE;
|
||||
|
||||
if (g_ascii_strcasecmp (expected, wanted) == 0) {
|
||||
g_string_free (ret, TRUE);
|
||||
|
@ -837,7 +839,7 @@ _RGB_pixel_order (const gchar * expected, const gchar * wanted)
|
|||
}
|
||||
|
||||
expect = g_ascii_strdown (expected, -1);
|
||||
want = g_ascii_strdown (wanted, -1);
|
||||
orig_want = want = g_ascii_strdown (wanted, -1);
|
||||
|
||||
if (strcmp (expect, "rgb16") == 0 || strcmp (expect, "bgr16") == 0) {
|
||||
gchar *temp = expect;
|
||||
|
@ -847,7 +849,7 @@ _RGB_pixel_order (const gchar * expected, const gchar * wanted)
|
|||
|
||||
if (strcmp (want, "rgb16") == 0 || strcmp (want, "bgr16") == 0) {
|
||||
gchar *temp = want;
|
||||
want = g_strndup (temp, 3);
|
||||
orig_want = want = g_strndup (temp, 3);
|
||||
g_free (temp);
|
||||
}
|
||||
|
||||
|
@ -859,7 +861,7 @@ _RGB_pixel_order (const gchar * expected, const gchar * wanted)
|
|||
len++;
|
||||
}
|
||||
g_free (want);
|
||||
want = new_want;
|
||||
orig_want = want = new_want;
|
||||
}
|
||||
|
||||
/* pad expect with 'a's */
|
||||
|
@ -884,7 +886,7 @@ _RGB_pixel_order (const gchar * expected, const gchar * wanted)
|
|||
|
||||
if (!(val = strchr (expect, needle))
|
||||
&& needle == 'a' && !(val = strchr (expect, 'x')))
|
||||
goto fail;
|
||||
goto out;
|
||||
|
||||
idx = (gint) (val - expect);
|
||||
|
||||
|
@ -892,11 +894,12 @@ _RGB_pixel_order (const gchar * expected, const gchar * wanted)
|
|||
want = &want[1];
|
||||
}
|
||||
|
||||
return g_string_free (ret, FALSE);
|
||||
discard_output = FALSE;
|
||||
out:
|
||||
g_free (orig_want);
|
||||
g_free (expect);
|
||||
|
||||
fail:
|
||||
g_string_free (ret, TRUE);
|
||||
return NULL;
|
||||
return g_string_free (ret, discard_output);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue