[vlc-commits] [Git][videolan/vlc][master] 2 commits: input: refactor `SlaveSourceAdd` error handling

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Wed Apr 6 21:49:43 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
83ffc437 by Alaric Senat at 2022-04-06T21:34:40+00:00
input: refactor `SlaveSourceAdd` error handling

- - - - -
caf66c91 by Alaric Senat at 2022-04-06T21:34:40+00:00
input: source: properly release on `SlaveAdd` failure

Fix a leak happening when an input slave fails to load.
Leak detected with asan:

```
Direct leak of 120 byte(s) in 1 object(s) allocated from:
    #0 0x7f56cb985ad7 in calloc (/lib64/libasan.so.6)
    #1 0x7f56cad22849 in InputSourceNew src/input/input.c:2605
    #2 0x7f56cad2c9ca in input_SlaveSourceAdd src/input/input.c:3408
    #3 0x7f56cad0f838 in LoadSlaves src/input/input.c:1164
    #4 0x7f56cad1219a in Init src/input/input.c:1360
    #5 0x7f56cad06092 in Run src/input/input.c:466
    #6 0x7f56c9998b19 in start_thread (/lib64/libc.so.6)
```

- - - - -


1 changed file:

- src/input/input.c


Changes:

=====================================
src/input/input.c
=====================================
@@ -3382,7 +3382,7 @@ static int input_SlaveSourceAdd( input_thread_t *p_input,
     if( ret != VLC_SUCCESS )
     {
         msg_Warn( p_input, "failed to add %s as slave", psz_uri );
-        return VLC_EGENERIC;
+        goto error;
     }
 
     if( i_type == SLAVE_TYPE_GENERIC )
@@ -3395,18 +3395,14 @@ static int input_SlaveSourceAdd( input_thread_t *p_input,
             if( demux_Control( priv->master->p_demux, DEMUX_GET_TIME, &i_time ) )
             {
                 msg_Err( p_input, "demux doesn't like DEMUX_GET_TIME" );
-                InputSourceDestroy( p_source );
-                input_source_Release( p_source );
-                return VLC_EGENERIC;
+                goto error;
             }
 
             if( demux_Control( p_source->p_demux,
                                DEMUX_SET_TIME, i_time, true ) )
             {
                 msg_Err( p_input, "seek failed for new slave" );
-                InputSourceDestroy( p_source );
-                input_source_Release( p_source );
-                return VLC_EGENERIC;
+                goto error;
             }
         }
 
@@ -3419,6 +3415,11 @@ static int input_SlaveSourceAdd( input_thread_t *p_input,
     TAB_APPEND( priv->i_slave, priv->slave, p_source );
 
     return VLC_SUCCESS;
+
+error:
+    InputSourceDestroy( p_source );
+    input_source_Release( p_source );
+    return VLC_EGENERIC;
 }
 
 static char *input_SubtitleFile2Uri( input_thread_t *p_input,



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/02293b1df3581f21be77b639153ad16207d94bec...caf66c9129b7e56b8fb4e96697e49652c591e1bb

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/02293b1df3581f21be77b639153ad16207d94bec...caf66c9129b7e56b8fb4e96697e49652c591e1bb
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list