Index: media/capture/video/win/sink_input_pin_win.cc |
diff --git a/media/capture/video/win/sink_input_pin_win.cc b/media/capture/video/win/sink_input_pin_win.cc |
index 0abd0a785c10cc83c3969d8de5f29502ec72f01a..e55316201d0fa4b16272a523c25aa6c27bec7d46 100644 |
--- a/media/capture/video/win/sink_input_pin_win.cc |
+++ b/media/capture/video/win/sink_input_pin_win.cc |
@@ -191,13 +191,14 @@ bool SinkInputPin::GetValidMediaType(int index, AM_MEDIA_TYPE* media_type) { |
HRESULT SinkInputPin::Receive(IMediaSample* sample) { |
const int length = sample->GetActualDataLength(); |
- uint8_t* buffer = NULL; |
- if (length <= 0) { |
- DLOG(WARNING) << "Media sample length is 0 or less."; |
+ if (length <= 0 || |
+ static_cast<size_t>(length) < resulting_format_.ImageAllocationSize()) { |
+ DLOG(WARNING) << "Wrong media sample length: " << length; |
return S_FALSE; |
} |
+ uint8_t* buffer = nullptr; |
if (FAILED(sample->GetPointer(&buffer))) |
return S_FALSE; |
@@ -208,7 +209,7 @@ HRESULT SinkInputPin::Receive(IMediaSample* sample) { |
timestamp = base::TimeDelta::FromMicroseconds(start_time / 10); |
} |
- observer_->FrameReceived(buffer, length, timestamp); |
+ observer_->FrameReceived(buffer, length, resulting_format_, timestamp); |
return S_OK; |
} |