[vlc-devel] [RFC 18/38] mux/avi: replaces usage of xrealloc

Filip Roséen filip at videolabs.io
Mon Jun 27 13:43:29 CEST 2016


---
 modules/mux/avi.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/modules/mux/avi.c b/modules/mux/avi.c
index 86e91c4..86a3372 100644
--- a/modules/mux/avi.c
+++ b/modules/mux/avi.c
@@ -566,9 +566,22 @@ static int Mux      ( sout_mux_t *p_mux )
             p_sys->idx1.i_entry_count++;
             if( p_sys->idx1.i_entry_count >= p_sys->idx1.i_entry_max )
             {
+                avi_idx1_entry_t * p_entry_orig     = p_sys->idx1.entry;
+                unsigned int       i_entry_max_orig = p_sys->idx1.i_entry_max;
+
                 p_sys->idx1.i_entry_max += 10000;
-                p_sys->idx1.entry = xrealloc( p_sys->idx1.entry,
+                p_sys->idx1.entry = realloc( p_sys->idx1.entry,
                        p_sys->idx1.i_entry_max * sizeof( avi_idx1_entry_t ) );
+
+                if( unlikely( !p_sys->idx1.entry ) )
+                {
+                    block_Release( p_data );
+
+                    p_sys->idx1.i_entry_max = i_entry_max_orig;
+                    p_sys->idx1.entry       = p_entry_orig;
+
+                    return VLC_ENOMEM;
+                }
             }
 
             p_data = block_Realloc( p_data, 8, p_data->i_buffer );
-- 
2.9.0



More information about the vlc-devel mailing list