Trying to use TagLib with mpd_music_dir unset resulted in a segfault

in TagLib when trying to open the file: its path was just the
filename (upstream git commit 1e1aba121d512f8fadc627d093c54e063416da67)
This commit is contained in:
dcoppa 2012-12-05 12:46:19 +00:00
parent 8f789047a2
commit 97133a8831
2 changed files with 50 additions and 2 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.14 2012/10/25 13:43:42 dcoppa Exp $
# $OpenBSD: Makefile,v 1.15 2012/12/05 12:46:19 dcoppa Exp $
COMMENT = ncurses mpd client inspired by ncmpc
DISTNAME = ncmpcpp-0.5.10
REVISION = 2
REVISION = 3
EXTRACT_SUFX = .tar.bz2

View File

@ -0,0 +1,48 @@
$OpenBSD: patch-src_song_info_cpp,v 1.1 2012/12/05 12:46:19 dcoppa Exp $
Trying to use TagLib with mpd_music_dir unset resulted in a segfault
in TagLib when trying to open the file: its path was just the
filename (upstream git commit 1e1aba121d512f8fadc627d093c54e063416da67)
--- src/song_info.cpp.orig Wed Dec 5 14:20:00 2012
+++ src/song_info.cpp Wed Dec 5 14:27:16 2012
@@ -99,27 +99,25 @@ void SongInfo::SwitchTo()
void SongInfo::PrepareSong(MPD::Song &s)
{
-# ifdef HAVE_TAGLIB_H
- std::string path_to_file;
- if (s.isFromDB())
- path_to_file += Config.mpd_music_dir;
- path_to_file += s.GetFile();
- TagLib::FileRef f(path_to_file.c_str());
- if (!f.isNull())
- s.SetComment(f.tag()->comment().to8Bit(1));
-# endif // HAVE_TAGLIB_H
-
*w << fmtBold << Config.color1 << "Filename: " << fmtBoldEnd << Config.color2 << s.GetName() << "\n" << clEnd;
*w << fmtBold << "Directory: " << fmtBoldEnd << Config.color2;
ShowTag(*w, s.GetDirectory());
*w << "\n\n" << clEnd;
*w << fmtBold << "Length: " << fmtBoldEnd << Config.color2 << s.GetLength() << "\n" << clEnd;
# ifdef HAVE_TAGLIB_H
- if (!f.isNull())
+ if (!Config.mpd_music_dir.empty())
{
- *w << fmtBold << "Bitrate: " << fmtBoldEnd << Config.color2 << f.audioProperties()->bitrate() << " kbps\n" << clEnd;
- *w << fmtBold << "Sample rate: " << fmtBoldEnd << Config.color2 << f.audioProperties()->sampleRate() << " Hz\n" << clEnd;
- *w << fmtBold << "Channels: " << fmtBoldEnd << Config.color2 << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << "\n" << clDefault;
+ std::string path_to_file;
+ if (s.isFromDB())
+ path_to_file += Config.mpd_music_dir;
+ path_to_file += s.GetFile();
+ TagLib::FileRef f(path_to_file.c_str());
+ if (!f.isNull())
+ {
+ *w << fmtBold << "Bitrate: " << fmtBoldEnd << Config.color2 << f.audioProperties()->bitrate() << " kbps\n" << clEnd;
+ *w << fmtBold << "Sample rate: " << fmtBoldEnd << Config.color2 << f.audioProperties()->sampleRate() << " Hz\n" << clEnd;
+ *w << fmtBold << "Channels: " << fmtBoldEnd << Config.color2 << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << "\n" << clDefault;
+ }
}
# endif // HAVE_TAGLIB_H
*w << clDefault;