title: TagLib - Segfault when fetching tag
body: <p>I'm using <code>TagLib</code> to get tags from audio files for my application that I'm making using wxWidgets. I have set it up to fetch multiple tags like artist, title, album and all, some files load fine, but some when loaded crashes my application and gives error saying,</p>
  <pre><code>./build.sh: line 12:  5891 Segmentation fault      ./SampleBrowser
  </code></pre>
  <p>I tried running with <code>GDB</code>,</p>
  <pre><code>Thread 1 &quot;SampleBrowser&quot; received signal SIGSEGV, Segmentation fault.
  Browser::AddSamples (this=0x555555a73e00, file=...) at ../src/Browser.cpp:248
  248         std::string Artist = File.tag()-&gt;artist().to8Bit(true);
  (gdb)
  </code></pre>
  <p>Here is the function that is responsible for fetching tags,</p>
  <pre><code>void Browser::AddSamples(wxString file)
  {
      TagLib::FileRef File (file);
  
      std::string Artist = File.tag()-&gt;artist().to8Bit(true);
      std::string Album = File.tag()-&gt;album().to8Bit(true);
      std::string Genre = File.tag()-&gt;genre().to8Bit(true);
      std::string Title = File.tag()-&gt;title().to8Bit(true);
      std::string Comment = File.tag()-&gt;comment().to8Bit(true);
  
      std::string Path = file.ToStdString();
      std::string Filename = file.AfterLast('/').BeforeLast('.').ToStdString();
  
      int Bitrate = File.audioProperties()-&gt;bitrate();
      int Channels = File.audioProperties()-&gt;channels();
      int Length = File.audioProperties()-&gt;lengthInMilliseconds();
      int LengthSec = File.audioProperties()-&gt;lengthInSeconds();
      int SampleRate = File.audioProperties()-&gt;sampleRate();
  
      Data.clear();
      Data.push_back(false);
      Data.push_back(Filename);
      Data.push_back(Artist);
      Data.push_back(wxString::Format(&quot;%d&quot;,Channels));
      Data.push_back(wxString::Format(&quot;%d&quot;,Length));
      Data.push_back(wxString::Format(&quot;%d&quot;,SampleRate));
      Data.push_back(wxString::Format(&quot;%d&quot;,Bitrate));
      Data.push_back(Comment);
  
      SampleListView-&gt;AppendItem(Data);
  
      db.InsertSample(0, Filename, Artist, Channels, Length,
                      SampleRate, Bitrate, Comment, Path);
  }
  </code></pre>
  <p>I can provide more information if needed.</p>