musikr: fix use-after-free in iostream shim

This commit is contained in:
Alexander Capehart 2025-02-21 08:49:41 -07:00
parent e22f811c81
commit 1dc33c1ae1
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47

View file

@ -29,16 +29,20 @@ namespace taglib_shim
bool isOpen() const override; bool isOpen() const override;
private: private:
std::string _name;
RsIOStream *rust_stream; RsIOStream *rust_stream;
}; };
WrappedRsIOStream::WrappedRsIOStream(RsIOStream *stream) : rust_stream(stream) {} WrappedRsIOStream::WrappedRsIOStream(RsIOStream *stream) : rust_stream(stream)
{
_name = std::move(std::string(rust_stream->name()));
}
WrappedRsIOStream::~WrappedRsIOStream() = default; WrappedRsIOStream::~WrappedRsIOStream() = default;
TagLib::FileName WrappedRsIOStream::name() const TagLib::FileName WrappedRsIOStream::name() const
{ {
return rust::string(rust_stream->name()).c_str(); return _name.c_str();
} }
TagLib::ByteVector WrappedRsIOStream::readBlock(size_t length) TagLib::ByteVector WrappedRsIOStream::readBlock(size_t length)