[gdk-pixbuf] pixops: Fix memory leaks in error paths
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf] pixops: Fix memory leaks in error paths
- Date: Tue, 7 Jan 2020 14:22:32 +0000 (UTC)
commit 017330de95a54eb2e1cd87428c3099208f7e0262
Author: Alex Henrie <alexhenrie24 gmail com>
Date: Tue Nov 26 17:04:58 2019 -0700
pixops: Fix memory leaks in error paths
Also remove redundant null checks before g_free, and use g_free instead
of g_clear_pointer because we never read the pointer value again.
gdk-pixbuf/pixops/pixops.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/gdk-pixbuf/pixops/pixops.c b/gdk-pixbuf/pixops/pixops.c
index f1b75f820..a1c3c9bfd 100644
--- a/gdk-pixbuf/pixops/pixops.c
+++ b/gdk-pixbuf/pixops/pixops.c
@@ -1838,7 +1838,7 @@ _pixops_composite_color_real (guchar *dest_buf,
filter.overall_alpha = overall_alpha / 255.;
if (!make_weights (&filter, interp_type, scale_x, scale_y))
- return;
+ goto free_tmp;
line_func = composite_line_color;
@@ -1850,8 +1850,8 @@ _pixops_composite_color_real (guchar *dest_buf,
g_free (filter.x.weights);
g_free (filter.y.weights);
- if (tmp_buf)
- g_free (tmp_buf);
+free_tmp:
+ g_free (tmp_buf);
}
void
@@ -1991,7 +1991,7 @@ _pixops_composite_real (guchar *dest_buf,
filter.overall_alpha = overall_alpha / 255.;
if (!make_weights (&filter, interp_type, scale_x, scale_y))
- return;
+ goto free_tmp;
if (filter.x.n == 2 && filter.y.n == 2 && dest_channels == 4 &&
src_channels == 4 && src_has_alpha && !dest_has_alpha)
@@ -2007,8 +2007,8 @@ _pixops_composite_real (guchar *dest_buf,
g_free (filter.x.weights);
g_free (filter.y.weights);
- if (tmp_buf)
- g_free (tmp_buf);
+free_tmp:
+ g_free (tmp_buf);
}
void
@@ -2396,7 +2396,7 @@ _pixops_scale_real (guchar *dest_buf,
filter.overall_alpha = 1.0;
if (!make_weights (&filter, interp_type, scale_x, scale_y))
- return;
+ goto free_tmp;
if (filter.x.n == 2 && filter.y.n == 2 && dest_channels == 3 && src_channels == 3)
line_func = scale_line_22_33;
@@ -2411,7 +2411,8 @@ _pixops_scale_real (guchar *dest_buf,
g_free (filter.x.weights);
g_free (filter.y.weights);
- g_clear_pointer (&tmp_buf, g_free);
+free_tmp:
+ g_free (tmp_buf);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]