diff mbox series

[v4l-utils] v4l2-compliance: fix assert on only read/write-only controls

Message ID 20200225135917.25466-1-p.zabel@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series [v4l-utils] v4l2-compliance: fix assert on only read/write-only controls | expand

Commit Message

Philipp Zabel Feb. 25, 2020, 1:59 p.m. UTC
If the driver only contains read-only (or write-only) controls,
total_vec is empty. In that case return immediately instead of
trying to access total_vec[0].

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 utils/v4l2-compliance/v4l2-test-controls.cpp | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/utils/v4l2-compliance/v4l2-test-controls.cpp b/utils/v4l2-compliance/v4l2-test-controls.cpp
index 735bc5a13c09..2a3f64e8bbec 100644
--- a/utils/v4l2-compliance/v4l2-test-controls.cpp
+++ b/utils/v4l2-compliance/v4l2-test-controls.cpp
@@ -749,6 +749,8 @@  int testExtendedControls(struct node *node)
 			multiple_classes = true;
 		total_vec.push_back(ctrl);
 	}
+	if (total_vec.empty())
+		return 0;
 
 	ctrls.count = total_vec.size();
 	ctrls.controls = &total_vec[0];