[vlc-commits] codec: opus: fix realloc usage

Francois Cartegnie git at videolan.org
Wed Dec 7 20:04:26 CET 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Dec  7 19:43:10 2016 +0100| [9df1339594923be2dbdb5a3e616b8d3b3d0f4f6c] | committer: Francois Cartegnie

codec: opus: fix realloc usage

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

 modules/codec/opus_header.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/modules/codec/opus_header.c b/modules/codec/opus_header.c
index 392b673..6d0ef49 100644
--- a/modules/codec/opus_header.c
+++ b/modules/codec/opus_header.c
@@ -267,9 +267,10 @@ static int comment_add(char **comments, size_t *length, const char *tag,
     size_t val_len = strlen(val);
     size_t len = (*length) + 4 + tag_len + val_len;
 
-    p = realloc(p, len);
-    if (p == NULL)
+    char *reaced = realloc(p, len);
+    if (reaced == NULL)
         return 1;
+    p = reaced;
 
     SetDWLE(p + *length, tag_len + val_len);          /* length of comment */
     if (tag) memcpy(p + *length + 4, tag, tag_len);         /* comment */
@@ -289,9 +290,10 @@ static int comment_pad(char **comments, size_t *length)
     /* Make sure there is at least "padding" worth of padding free, and
        round up to the maximum that fits in the current ogg segments. */
     size_t newlen = ((*length + padding) / 255 + 1) * 255 - 1;
-    p = realloc(p, newlen);
-    if (p == NULL)
+    char *reaced = realloc(p, newlen);
+    if (reaced == NULL)
         return 1;
+    p = reaced;
 
     memset(p + *length, 0, newlen - *length);
     *comments = p;



More information about the vlc-commits mailing list