mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +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);
|
GString *ret = g_string_sized_new (4);
|
||||||
gchar *expect, *want;
|
gchar *expect, *want;
|
||||||
|
gchar *orig_want;
|
||||||
int len;
|
int len;
|
||||||
|
gboolean discard_output = TRUE;
|
||||||
|
|
||||||
if (g_ascii_strcasecmp (expected, wanted) == 0) {
|
if (g_ascii_strcasecmp (expected, wanted) == 0) {
|
||||||
g_string_free (ret, TRUE);
|
g_string_free (ret, TRUE);
|
||||||
|
@ -837,7 +839,7 @@ _RGB_pixel_order (const gchar * expected, const gchar * wanted)
|
||||||
}
|
}
|
||||||
|
|
||||||
expect = g_ascii_strdown (expected, -1);
|
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) {
|
if (strcmp (expect, "rgb16") == 0 || strcmp (expect, "bgr16") == 0) {
|
||||||
gchar *temp = expect;
|
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) {
|
if (strcmp (want, "rgb16") == 0 || strcmp (want, "bgr16") == 0) {
|
||||||
gchar *temp = want;
|
gchar *temp = want;
|
||||||
want = g_strndup (temp, 3);
|
orig_want = want = g_strndup (temp, 3);
|
||||||
g_free (temp);
|
g_free (temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -859,7 +861,7 @@ _RGB_pixel_order (const gchar * expected, const gchar * wanted)
|
||||||
len++;
|
len++;
|
||||||
}
|
}
|
||||||
g_free (want);
|
g_free (want);
|
||||||
want = new_want;
|
orig_want = want = new_want;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pad expect with 'a's */
|
/* pad expect with 'a's */
|
||||||
|
@ -884,7 +886,7 @@ _RGB_pixel_order (const gchar * expected, const gchar * wanted)
|
||||||
|
|
||||||
if (!(val = strchr (expect, needle))
|
if (!(val = strchr (expect, needle))
|
||||||
&& needle == 'a' && !(val = strchr (expect, 'x')))
|
&& needle == 'a' && !(val = strchr (expect, 'x')))
|
||||||
goto fail;
|
goto out;
|
||||||
|
|
||||||
idx = (gint) (val - expect);
|
idx = (gint) (val - expect);
|
||||||
|
|
||||||
|
@ -892,11 +894,12 @@ _RGB_pixel_order (const gchar * expected, const gchar * wanted)
|
||||||
want = &want[1];
|
want = &want[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_string_free (ret, FALSE);
|
discard_output = FALSE;
|
||||||
|
out:
|
||||||
|
g_free (orig_want);
|
||||||
|
g_free (expect);
|
||||||
|
|
||||||
fail:
|
return g_string_free (ret, discard_output);
|
||||||
g_string_free (ret, TRUE);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue