From 97133a883110167553c91978f802c6a06c6a884b Mon Sep 17 00:00:00 2001 From: dcoppa Date: Wed, 5 Dec 2012 12:46:19 +0000 Subject: [PATCH] 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) --- audio/ncmpcpp/Makefile | 4 +- audio/ncmpcpp/patches/patch-src_song_info_cpp | 48 +++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 audio/ncmpcpp/patches/patch-src_song_info_cpp diff --git a/audio/ncmpcpp/Makefile b/audio/ncmpcpp/Makefile index e8978d6331b..cc6f22d18b1 100644 --- a/audio/ncmpcpp/Makefile +++ b/audio/ncmpcpp/Makefile @@ -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 diff --git a/audio/ncmpcpp/patches/patch-src_song_info_cpp b/audio/ncmpcpp/patches/patch-src_song_info_cpp new file mode 100644 index 00000000000..6ab76339b6c --- /dev/null +++ b/audio/ncmpcpp/patches/patch-src_song_info_cpp @@ -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;