vlc | branch: master | Hugo Beauzée-Luyssen <h...@beauzee.fr> | Wed Feb 15 15:03:20 2017 +0100| [e9ccb209631f1382867bc3e31f08e5a664519c80] | committer: Hugo Beauzée-Luyssen
chromecast: Fix undefined behavior in case of error Removing an element from a container and using the iterator pointing to the removed element afterward is UB > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e9ccb209631f1382867bc3e31f08e5a664519c80 --- modules/stream_out/chromecast/cast.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/stream_out/chromecast/cast.cpp index 2b9ccf1..89fe911 100644 --- a/modules/stream_out/chromecast/cast.cpp +++ b/modules/stream_out/chromecast/cast.cpp @@ -317,15 +317,17 @@ int sout_stream_sys_t::UpdateOutput( sout_stream_t *p_stream ) } /* check the streams we can actually add */ - for (std::vector<sout_stream_id_sys_t*>::iterator it = streams.begin(); it != streams.end(); ++it) + for (std::vector<sout_stream_id_sys_t*>::iterator it = streams.begin(); it != streams.end(); ) { sout_stream_id_sys_t *p_sys_id = *it; p_sys_id->p_sub_id = sout_StreamIdAdd( p_out, &p_sys_id->fmt ); if ( p_sys_id->p_sub_id == NULL ) { msg_Err( p_stream, "can't handle %4.4s stream", (char *)&p_sys_id->fmt.i_codec ); - streams.erase( it, it ); + it = streams.erase( it ); } + else + ++it; } if ( !streams.empty() ) _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits