1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix(video): fix a use-after-free with VideoFrame

This commit is contained in:
initramfs 2016-08-02 13:28:49 +08:00
parent 8ef89a267e
commit 8487dcecf8
No known key found for this signature in database
GPG Key ID: 78B8BDF87E9EF0AF

View File

@ -90,7 +90,7 @@ QReadWriteLock VideoFrame::refsLock {};
* @param freeSourceFrame whether to free the source frame buffers or not.
*/
VideoFrame::VideoFrame(IDType sourceID, AVFrame* sourceFrame, QRect dimensions, int pixFmt, bool freeSourceFrame)
: frameID(frameIDs.fetch_add(std::memory_order_relaxed)),
: frameID(frameIDs++),
sourceID(sourceID),
sourceDimensions(dimensions),
sourcePixelFormat(pixFmt),
@ -483,6 +483,11 @@ void VideoFrame::storeAVFrame(AVFrame* frame, const QSize& dimensions, const int
*/
void VideoFrame::deleteFrameBuffer()
{
// An empty framebuffer represents a frame that's already been freed
if(frameBuffer.empty()){
return;
}
for(const auto& frameIterator : frameBuffer)
{
AVFrame* frame = frameIterator.second;