Fix leaking memory or file handles in StreamDataBlock descendants
StreamDataBlock needs a virtual d'tor since it is supposed to be subclassed but the d'tor will be called on the base type. The leaking file handles were observed by invoking the tests with strace, eg.: strace -e trace=file,close ./tagparser_tests
This commit is contained in:
parent
edad4e19ab
commit
6f2dcdc2d9
|
@ -57,6 +57,13 @@ StreamDataBlock::StreamDataBlock(const std::function<std::istream &()> &stream,
|
|||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Discards buffered data.
|
||||
*/
|
||||
StreamDataBlock::~StreamDataBlock()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Buffers the data block. Buffered data can be accessed via buffer().
|
||||
*/
|
||||
|
@ -95,7 +102,7 @@ void StreamDataBlock::copyTo(ostream &stream) const
|
|||
* \throws Throws ios_base::failure when an IO error occurs.
|
||||
*/
|
||||
FileDataBlock::FileDataBlock(const string &path, Diagnostics &diag)
|
||||
: m_fileInfo(new MediaFileInfo)
|
||||
: m_fileInfo(make_unique<MediaFileInfo>())
|
||||
{
|
||||
m_fileInfo->setPath(path);
|
||||
m_fileInfo->open(true);
|
||||
|
|
|
@ -17,6 +17,7 @@ public:
|
|||
StreamDataBlock(const std::function<std::istream &()> &stream, std::istream::off_type startOffset = 0,
|
||||
std::ios_base::seekdir startDir = std::ios_base::beg, std::istream::off_type endOffset = 0,
|
||||
std::ios_base::seekdir endDir = std::ios_base::end);
|
||||
virtual ~StreamDataBlock();
|
||||
|
||||
std::istream &stream() const;
|
||||
std::istream::pos_type startOffset() const;
|
||||
|
|
|
@ -620,7 +620,7 @@ void OverallTests::setMkvTestMetaData()
|
|||
newTag->setValue(KnownField::PartNumber, m_testPartNumber);
|
||||
newTag->setValue(KnownField::TotalParts, m_testTotalParts);
|
||||
// assign an attachment
|
||||
AbstractAttachment *attachment = container->createAttachment();
|
||||
AbstractAttachment *const attachment = container->createAttachment();
|
||||
CPPUNIT_ASSERT_MESSAGE("create attachment", attachment);
|
||||
attachment->setFile(TestUtilities::testFilePath("matroska_wave1/logo3_256x256.png"), m_diag);
|
||||
attachment->setMimeType("image/png");
|
||||
|
|
Loading…
Reference in New Issue