From a105c311ad8109c5fc8012b4a76dce2e3f0abf57 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Wed, 12 Aug 2020 16:02:23 +0300
Subject: [PATCH] Fix for bad param set

---
 components/streams/src/receiver.cpp | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/components/streams/src/receiver.cpp b/components/streams/src/receiver.cpp
index 738e3f0bf..dc13bc529 100644
--- a/components/streams/src/receiver.cpp
+++ b/components/streams/src/receiver.cpp
@@ -70,8 +70,8 @@ ftl::streams::BaseBuilder &Receiver::builder(uint32_t id) {
 		b->setID(id);
 		b->setPool(pool_);
 		fb->setBufferSize(value("frameset_buffer_size", 0));
-		fb->setBufferSize(value("max_buffer_size", 16));
-		fb->setBufferSize(value("completion_size", 8));
+		fb->setMaxBufferSize(value("max_buffer_size", 16));
+		fb->setCompletionSize(value("completion_size", 8));
 		handles_[id] = std::move(fb->onFrameSet([this](const ftl::data::FrameSetPtr& fs) {
 			callback_.trigger(fs);
 			return true;
@@ -255,14 +255,10 @@ void Receiver::_processVideo(const StreamPacket &spkt, const Packet &pkt) {
 
 	auto [tx,ty] = ftl::codecs::chooseTileConfig(pkt.frame_count);
 
-	// Get the frameset
-	auto &build = builder(spkt.streamID);
-	auto fs = build.get(spkt.timestamp, spkt.frame_number+pkt.frame_count-1);
-
 	int width = ividstate.width; //calibration.width;
 	int height = ividstate.height; //calibration.height;
 
-	if (width == 0 || height == 0) {
+	if (width <= 0 || height <= 0 || width > 9000 || height > 9000) {
 		// Attempt to retry the decode later
 		// Make a copy of the packets into a thread job
 		// FIXME: Check that thread pool does not explode
@@ -314,6 +310,10 @@ void Receiver::_processVideo(const StreamPacket &spkt, const Packet &pkt) {
 		}
 	}
 
+	// Get the frameset
+	auto &build = builder(spkt.streamID);
+	auto fs = build.get(spkt.timestamp, spkt.frame_number+pkt.frame_count-1);
+
 	if (!fs) {
 		LOG(WARNING) << "Dropping a video frame";
 		return;
-- 
GitLab