# HG changeset patch # User Chris Cannam # Date 1484242199 0 # Node ID b812df0351d99b5d7ca4de80ae728614adf68cba # Parent 39271c98cbdd46efa8fd46608d5f794e0bb16bf2 Fix (I think) crash on exit on Windows having loaded an mp3 diff -r 39271c98cbdd -r b812df0351d9 data/fileio/MP3FileReader.cpp --- a/data/fileio/MP3FileReader.cpp Tue Jan 10 16:56:48 2017 +0000 +++ b/data/fileio/MP3FileReader.cpp Thu Jan 12 17:29:59 2017 +0000 @@ -32,6 +32,14 @@ #include #endif +#ifdef _WIN32 +#include +#include +#else +#include +#include +#endif + #include #include @@ -176,7 +184,13 @@ #ifdef HAVE_ID3TAG - id3_file *file = id3_file_fdopen(fd, ID3_FILE_MODE_READONLY); +#ifdef _WIN32 + int id3fd = _dup(fd); +#else + int id3fd = dup(fd); +#endif + + id3_file *file = id3_file_fdopen(id3fd, ID3_FILE_MODE_READONLY); if (!file) return; // We can do this a lot more elegantly, but we'll leave that for @@ -185,7 +199,7 @@ id3_tag *tag = id3_file_tag(file); if (!tag) { SVDEBUG << "MP3FileReader::loadTags: No ID3 tag found" << endl; - id3_file_close(file); + id3_file_close(file); // also closes our dup'd fd return; } @@ -206,8 +220,7 @@ } } - // We don't id3_file_close(file) because that closes the fd, which - // was only lent to us + id3_file_close(file); // also closes our dup'd fd #else SVDEBUG << "MP3FileReader::loadTags: ID3 tag support not compiled in" << endl;