Commit 9fd65064 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Fix crash when constructing a string with a NULL pointer

parent 8cc9b22d
......@@ -111,7 +111,9 @@ void Media::addOptionFlag(const std::string& psz_options, unsigned i_flags)
std::string Media::mrl()
{
char * c_result = libvlc_media_get_mrl(m_obj);
char* c_result = libvlc_media_get_mrl(m_obj);
if ( c_result == NULL )
return std::string();
std::string result = c_result;
libvlc_free(c_result);
return result;
......@@ -125,7 +127,9 @@ Media Media::duplicate()
std::string Media::meta(libvlc_meta_t e_meta)
{
char * c_result = libvlc_media_get_meta(m_obj, e_meta);
char* c_result = libvlc_media_get_meta(m_obj, e_meta);
if ( c_result == NULL )
return std::string();
std::string result = c_result;
libvlc_free(c_result);
return result;
......
......@@ -45,6 +45,8 @@ MediaDiscoverer* MediaDiscoverer::create( Instance &inst, const std::string& nam
std::string MediaDiscoverer::localizedName()
{
char* c_result = libvlc_media_discoverer_localized_name(m_obj);
if ( c_result == NULL )
return std::string();
std::string result = c_result;
libvlc_free(c_result);
return result;
......
......@@ -479,7 +479,9 @@ void MediaPlayer::setScale(float f_factor)
std::string MediaPlayer::aspectRatio()
{
char * c_result = libvlc_video_get_aspect_ratio(m_obj);
char* c_result = libvlc_video_get_aspect_ratio(m_obj);
if ( c_result == NULL )
return std::string();
std::string result = c_result;
libvlc_free(c_result);
return result;
......@@ -540,7 +542,9 @@ std::vector<TrackDescription> MediaPlayer::chapterDescription(int i_title)
std::string MediaPlayer::cropGeometry()
{
char * c_result = libvlc_video_get_crop_geometry(m_obj);
char* c_result = libvlc_video_get_crop_geometry(m_obj);
if ( c_result == NULL )
return std::string();
std::string result = c_result;
libvlc_free(c_result);
return result;
......@@ -599,7 +603,9 @@ int MediaPlayer::marqueeInt(unsigned option)
std::string MediaPlayer::marqueeString(unsigned option)
{
char * c_result = libvlc_video_get_marquee_string(m_obj, option);
char* c_result = libvlc_video_get_marquee_string(m_obj, option);
if ( c_result == NULL )
return std::string();
std::string result = c_result;
libvlc_free(c_result);
return result;
......
......@@ -108,7 +108,7 @@ uint32_t MediaTrack::fpsDen() const
return m_fpsDen;
}
const std::string&MediaTrack::encoding() const
const std::string& MediaTrack::encoding() const
{
return m_encoding;
}
......@@ -128,12 +128,12 @@ uint32_t MediaTrack::bitrate() const
return m_bitrate;
}
const std::string&MediaTrack::language() const
const std::string& MediaTrack::language() const
{
return m_language;
}
const std::string&MediaTrack::description() const
const std::string& MediaTrack::description() const
{
return m_description;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment