[vlc-commits] demux: ts: use fail proof realloc

Francois Cartegnie git at videolan.org
Sun Mar 6 21:17:55 CET 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Mar  6 19:29:31 2016 +0100| [f28e8996c46fc77fe8a7097aa521424e69c58e9b] | committer: Francois Cartegnie

demux: ts: use fail proof realloc

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

 modules/demux/mpeg/ts_psi_eit.c |   21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/modules/demux/mpeg/ts_psi_eit.c b/modules/demux/mpeg/ts_psi_eit.c
index 407236b..8ddf9be 100644
--- a/modules/demux/mpeg/ts_psi_eit.c
+++ b/modules/demux/mpeg/ts_psi_eit.c
@@ -390,7 +390,7 @@ static void EITCallBack( demux_t *p_demux,
         dvbpsi_descriptor_t *p_dr;
         char                *psz_name = NULL;
         char                *psz_text = NULL;
-        char                *psz_extra = strdup("");
+        char                *psz_extra = NULL;
         int64_t i_start;
         int i_duration;
         int i_min_age = 0;
@@ -454,10 +454,21 @@ static void EITCallBack( demux_t *p_demux,
                         {
                             msg_Dbg( p_demux, "       - text='%s'", psz_text );
 
-                            psz_extra = xrealloc( psz_extra,
-                                   strlen(psz_extra) + strlen(psz_text) + 1 );
-                            strcat( psz_extra, psz_text );
-                            free( psz_text );
+                            if( psz_extra )
+                            {
+                                size_t i_extra = strlen( psz_extra ) + strlen( psz_text ) + 1;
+                                char *psz_realloc = realloc( psz_extra, i_extra );
+                                if( psz_realloc )
+                                {
+                                    psz_extra = psz_realloc;
+                                    strcat( psz_extra, psz_text );
+                                }
+                                free( psz_text );
+                            }
+                            else
+                            {
+                                psz_extra = psz_text;
+                            }
                         }
                     }
 



More information about the vlc-commits mailing list