From 5ab122366ba0df6b3908973c06ef054704628fd6 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 16 Dec 2004 11:39:00 +0000 Subject: [PATCH] gst/: Fix memleak (#159215). Original commit message from CVS: Reviewed by: Ronald S. Bultje * gst-libs/gst/resample/resample.c: (gst_resample_close): * gst-libs/gst/resample/resample.h: * gst/audioscale/gstaudioscale.c: Fix memleak (#159215). --- ChangeLog | 9 +++++++++ gst-libs/gst/resample/resample.c | 22 ++++++++++++++++++---- gst-libs/gst/resample/resample.h | 3 ++- gst/audioscale/gstaudioscale.c | 1 + 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1957cac..a5a0980 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-12-16 Sebastien Cote + + Reviewed by: Ronald S. Bultje + + * gst-libs/gst/resample/resample.c: (gst_resample_close): + * gst-libs/gst/resample/resample.h: + * gst/audioscale/gstaudioscale.c: + Fix memleak (#159215). + 2004-12-16 Toni Willberg Reviewed by: Ronald S. Bultje diff --git a/gst-libs/gst/resample/resample.c b/gst-libs/gst/resample/resample.c index 63ade39..cd89915 100644 --- a/gst-libs/gst/resample/resample.c +++ b/gst-libs/gst/resample/resample.c @@ -133,6 +133,22 @@ gst_resample_reinit (gst_resample_t * r) } } +void +gst_resample_close (gst_resample_t * r) +{ + if (r->buffer) { + free (r->buffer); + r->buffer = NULL; + r->buffer_len = 0; + } + if (r->hack_union.s.out_tmp) { + free (r->hack_union.s.out_tmp); + r->hack_union.s.out_tmp = NULL; + r->hack_union.s.out_tmp_len = 0; + } + +} + /* * Prepare to be confused. * @@ -252,8 +268,7 @@ gst_resample_nearest_s16 (gst_resample_t * r) SCALE_LOOP (o_ptr[0] = i_ptr[0], 1); break; case 2: - SCALE_LOOP (o_ptr[0] = i_ptr[0]; - o_ptr[1] = i_ptr[1], 2); + SCALE_LOOP (o_ptr[0] = i_ptr[0]; o_ptr[1] = i_ptr[1], 2); break; default: { @@ -612,8 +627,7 @@ gst_resample_nearest_float (gst_resample_t * r) SCALE_LOOP (o_ptr[0] = i_ptr[0], 1); break; case 2: - SCALE_LOOP (o_ptr[0] = i_ptr[0]; - o_ptr[1] = i_ptr[1], 2); + SCALE_LOOP (o_ptr[0] = i_ptr[0]; o_ptr[1] = i_ptr[1], 2); break; default: { diff --git a/gst-libs/gst/resample/resample.h b/gst-libs/gst/resample/resample.h index 34d6f9d..e887951 100644 --- a/gst-libs/gst/resample/resample.h +++ b/gst-libs/gst/resample/resample.h @@ -98,7 +98,8 @@ void gst_resample_init(gst_resample_t *r); void gst_resample_reinit(gst_resample_t *r); +void gst_resample_close (gst_resample_t * r); + void gst_resample_scale(gst_resample_t *r, void *i_buf, unsigned int size); #endif /* __GST_RESAMPLE_H__ */ - diff --git a/gst/audioscale/gstaudioscale.c b/gst/audioscale/gstaudioscale.c index 71f0841..e92d689 100644 --- a/gst/audioscale/gstaudioscale.c +++ b/gst/audioscale/gstaudioscale.c @@ -587,6 +587,7 @@ static void gst_audioscale_dispose (GObject * object) Audioscale *audioscale = GST_AUDIOSCALE (object); if (audioscale->gst_resample) { + gst_resample_close (audioscale->gst_resample); g_free (audioscale->gst_resample); audioscale->gst_resample = NULL; } -- 2.7.4