Commit 4cc48629 authored by Jan Grulich's avatar Jan Grulich Committed by Pier Angelo Vendrame
Browse files

Bug 2029894 - WebRTC backport: Fix double mapoffset application in PipeWire...

Bug 2029894 - WebRTC backport: Fix double mapoffset application in PipeWire video capture  a=dmeehan

mmap() with mapoffset as the file offset already returns a pointer to
the data at that offset, so passing it again to SPA_MEMBER was reading
mapoffset bytes past the mapped region. Also queue the buffer back to
PipeWire before returning on mmap failure to avoid leaking it.

This is a simple backport of an WebRTC upstream change.

Upstream commit: 9ee59b4ab343540923a23edd6429064c22571c3b

Original Revision: https://phabricator.services.mozilla.com/D296761

Differential Revision: https://phabricator.services.mozilla.com/D297303
parent c281541a
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -456,12 +456,12 @@ void VideoCaptureModulePipeWire::ProcessBuffers() {
      if (!frame) {
        RTC_LOG(LS_ERROR) << "Failed to mmap the memory: "
                          << std::strerror(errno);
        pw_stream_queue_buffer(stream_, buffer);
        return;
      }

      IncomingFrame(
          SPA_MEMBER(frame.get(), spaBuffer->datas[0].mapoffset, uint8_t),
          spaBuffer->datas[0].chunk->size, configured_capability_);
      IncomingFrame(frame.get(), spaBuffer->datas[0].chunk->size,
                    configured_capability_);
    } else {  // SPA_DATA_MemPtr
      IncomingFrame(static_cast<uint8_t*>(spaBuffer->datas[0].data),
                    spaBuffer->datas[0].chunk->size, configured_capability_);
+1 −0
Original line number Diff line number Diff line
We cherry-picked this in bug 2029894.