[vlc-commits] chromecast: Account for exceptions thrown by constructors
Hugo Beauzée-Luyssen
git at videolan.org
Thu Mar 1 11:38:21 CET 2018
vlc/vlc-3.0 | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Mar 1 11:29:08 2018 +0100| [4f1c726848f9c999ce8095da9aa203ac2cfd47c9] | committer: Hugo Beauzée-Luyssen
chromecast: Account for exceptions thrown by constructors
std::nothrow will just prevent std::bad_alloc from being thrown, but
some of the member variables' constructors will throw std::runtime_error
(cherry picked from commit de91aed8dc20f5202ff4789a3ab432837fbc7be6)
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=4f1c726848f9c999ce8095da9aa203ac2cfd47c9
---
modules/stream_out/chromecast/cast.cpp | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/stream_out/chromecast/cast.cpp
index f9a3663925..c4965e3ee7 100644
--- a/modules/stream_out/chromecast/cast.cpp
+++ b/modules/stream_out/chromecast/cast.cpp
@@ -1325,10 +1325,17 @@ static int Open(vlc_object_t *p_this)
b_supports_video = var_GetBool(p_stream, SOUT_CFG_PREFIX "video");
- p_sys = new(std::nothrow) sout_stream_sys_t( httpd_host, p_intf, b_supports_video,
- i_local_server_port );
- if (unlikely(p_sys == NULL))
+ try
+ {
+ p_sys = new sout_stream_sys_t( httpd_host, p_intf, b_supports_video,
+ i_local_server_port );
+ }
+ catch ( std::exception& ex )
+ {
+ msg_Err( p_stream, "Failed to instantiate sout_stream_sys_t: %s", ex.what() );
+ p_sys = NULL;
goto error;
+ }
p_intf->setOnInputEventCb(on_input_event_cb, p_stream);
More information about the vlc-commits
mailing list