Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit 6fe9dfd

Browse files
[GStreamer] use-after-free in MockVideoCaptureSource
https://bugs.webkit.org/show_bug.cgi?id=189462 Reviewed by Xabier Rodriguez-Calvar. * platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp: (WebCore::WrappedMockRealtimeVideoSource::updateSampleBuffer): Copy the BGRA data before passing ownership to GStreamer. Also include a few code style cosmetic changes. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@235890 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent b0f1f0d commit 6fe9dfd

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

Source/WebCore/ChangeLog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2018-09-11 Philippe Normand <[email protected]>
2+
3+
[GStreamer] use-after-free in MockVideoCaptureSource
4+
https://bugs.webkit.org/show_bug.cgi?id=189462
5+
6+
Reviewed by Xabier Rodriguez-Calvar.
7+
8+
* platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp:
9+
(WebCore::WrappedMockRealtimeVideoSource::updateSampleBuffer):
10+
Copy the BGRA data before passing ownership to GStreamer. Also
11+
include a few code style cosmetic changes.
12+
113
2018-09-11 Jiewen Tan <[email protected]>
214

315
[WebAuthN] Polish AuthenticatorManager and rename it to AuthenticatorCoordinator

Source/WebCore/platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,24 @@ class WrappedMockRealtimeVideoSource : public MockRealtimeVideoSource {
4040

4141
void updateSampleBuffer()
4242
{
43-
int fpsNumerator, fpsDenominator;
4443
auto imageBuffer = this->imageBuffer();
45-
4644
if (!imageBuffer)
4745
return;
4846

47+
int fpsNumerator, fpsDenominator;
4948
gst_util_double_to_fraction(frameRate(), &fpsNumerator, &fpsDenominator);
49+
auto imageSize = imageBuffer->internalSize();
50+
auto caps = adoptGRef(gst_caps_new_simple("video/x-raw",
51+
"format", G_TYPE_STRING, "BGRA",
52+
"width", G_TYPE_INT, imageSize.width(),
53+
"height", G_TYPE_INT, imageSize.height(),
54+
"framerate", GST_TYPE_FRACTION, fpsNumerator, fpsDenominator, nullptr));
5055
auto data = imageBuffer->toBGRAData();
5156
auto size = data.size();
52-
auto image_size = imageBuffer->internalSize();
53-
auto gstsample = gst_sample_new(gst_buffer_new_wrapped(static_cast<guint8*>(data.releaseBuffer().get()), size),
54-
adoptGRef(gst_caps_new_simple("video/x-raw",
55-
"format", G_TYPE_STRING, "BGRA",
56-
"width", G_TYPE_INT, image_size.width(),
57-
"height", G_TYPE_INT, image_size.height(),
58-
"framerate", GST_TYPE_FRACTION, fpsNumerator, fpsDenominator,
59-
nullptr)).get(),
60-
nullptr, nullptr);
61-
62-
auto sample = MediaSampleGStreamer::create(WTFMove(gstsample),
63-
WebCore::FloatSize(), String());
64-
videoSampleAvailable(sample);
57+
auto buffer = adoptGRef(gst_buffer_new_wrapped(g_memdup(data.releaseBuffer().get(), size), size));
58+
auto gstSample = adoptGRef(gst_sample_new(buffer.get(), caps.get(), nullptr, nullptr));
59+
60+
videoSampleAvailable(MediaSampleGStreamer::create(WTFMove(gstSample), FloatSize(), String()));
6561
}
6662
};
6763

0 commit comments

Comments
 (0)