[vlmc-devel] [PATCH] MLTBackend: Error checking on m_mltRepo init
yikei lu
luyikei.qmltu at gmail.com
Thu Jul 21 13:09:58 CEST 2016
Hi
http://www.cplusplus.com/reference/new/operator%20new/
(1) throwing allocation
Allocates size bytes of storage, suitably aligned to represent any
object of that size, and returns a non-null pointer to the first byte
of this block.
"On failure, it throws a bad_alloc exception."
2016-07-21 20:08 GMT+09:00 Paweł Goliński <golpaw1 at gmail.com>:
>
> Wiadomość napisana przez yikei lu <luyikei.qmltu at gmail.com> w dniu
> 21.07.2016, o godz. 13:04:
>
> 2016-07-21 20:01 GMT+09:00 Pawel Golinski <golpaw1 at gmail.com>:
>
> ---
> src/Backend/MLT/MLTBackend.cpp | 23 +++++++++++++++--------
> 1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/src/Backend/MLT/MLTBackend.cpp b/src/Backend/MLT/MLTBackend.cpp
> index 3d39930..44b9ba9 100644
> --- a/src/Backend/MLT/MLTBackend.cpp
> +++ b/src/Backend/MLT/MLTBackend.cpp
> @@ -54,17 +54,24 @@ MLTBackend::MLTBackend()
> m_mltRepo = Mlt::Factory::init();
> m_profile.setFrameRate( 2997, 100 );
>
> - for ( int i = 0; i < m_mltRepo->filters()->count(); ++i )
> + if ( m_mltRepo )
>
>
> m_mltRepo will never be nullptr.
>
>
> "m_mltRepo = Mlt::Factory::init();”
> This line calls a function which returns a pointer allocated using „new”.
>
> „
> Repository *Factory::init( const char *directory )
> {
> return new Repository( mlt_factory_init( directory ) );
> }
> „
>
> So it can.
>
> {
> - auto pro = std::unique_ptr<Mlt::Properties>( m_mltRepo->metadata(
> filter_type, m_mltRepo->filters()->get_name( i ) ) );
> - auto filterInfo = new MLTFilterInfo;
> - filterInfo->setProperties( pro.get() );
> - if ( filterInfo->identifier().empty() == true )
> + for ( int i = 0; i < m_mltRepo->filters()->count(); ++i )
> {
> - delete filterInfo;
> - continue;
> + auto pro = std::unique_ptr<Mlt::Properties>(
> m_mltRepo->metadata( filter_type, m_mltRepo->filters()->get_name( i ) ) );
> + auto filterInfo = new MLTFilterInfo;
> + filterInfo->setProperties( pro.get() );
> + if ( filterInfo->identifier().empty() == true )
> + {
> + delete filterInfo;
> + continue;
> + }
> + m_availableFilters[ filterInfo->identifier() ] = filterInfo;
> }
> - m_availableFilters[ filterInfo->identifier() ] = filterInfo;
> + }
> + else
> + {
> + throw InvalidServiceException();
> }
> }
>
> --
> 2.7.4 (Apple Git-66)
>
> _______________________________________________
> Vlmc-devel mailing list
> Vlmc-devel at videolan.org
> https://mailman.videolan.org/listinfo/vlmc-devel
>
> _______________________________________________
> Vlmc-devel mailing list
> Vlmc-devel at videolan.org
> https://mailman.videolan.org/listinfo/vlmc-devel
>
>
>
> _______________________________________________
> Vlmc-devel mailing list
> Vlmc-devel at videolan.org
> https://mailman.videolan.org/listinfo/vlmc-devel
>
More information about the Vlmc-devel
mailing list