[vlc-commits] flac packetizer: avoid realloc

Rafaël Carré git at videolan.org
Sat Nov 16 01:12:00 CET 2013


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Fri Nov 15 21:29:35 2013 +0100| [72bef01564d35fa3bcdc4ccf93dd89d20b145a20] | committer: Rafaël Carré

flac packetizer: avoid realloc

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=72bef01564d35fa3bcdc4ccf93dd89d20b145a20
---

 modules/packetizer/flac.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/modules/packetizer/flac.c b/modules/packetizer/flac.c
index a7e7aeb..c487a2b 100644
--- a/modules/packetizer/flac.c
+++ b/modules/packetizer/flac.c
@@ -145,8 +145,12 @@ static void ProcessHeader(decoder_t *p_dec)
     p_sys->b_stream_info = true;
 
     p_dec->fmt_out.i_extra = i_extra;
-    p_dec->fmt_out.p_extra = xrealloc(p_dec->fmt_out.p_extra, i_extra);
-    memcpy(p_dec->fmt_out.p_extra, p_extra, i_extra);
+    free(p_dec->fmt_out.p_extra);
+    p_dec->fmt_out.p_extra = malloc(i_extra);
+    if (p_dec->fmt_out.p_extra)
+        memcpy(p_dec->fmt_out.p_extra, p_extra, i_extra);
+    else
+        p_dec->fmt_out.i_extra = 0;
 }
 
 /* Will return 0xffffffffffffffff for an invalid utf-8 sequence */



More information about the vlc-commits mailing list