From 14529b6d1c4a6d405b23157eca8a4b0bec632e00 Mon Sep 17 00:00:00 2001 From: Umang Jain Date: Fri, 4 Dec 2020 12:24:50 +0530 Subject: simple-cam: Early return if no cameras are found on the system Failing to do so, the codepath will segfault while trying to acquire a non-existent camera. Signed-off-by: Umang Jain Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- simple-cam.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'simple-cam.cpp') diff --git a/simple-cam.cpp b/simple-cam.cpp index fefc980..bfe30d7 100644 --- a/simple-cam.cpp +++ b/simple-cam.cpp @@ -307,6 +307,13 @@ int main() for (std::unique_ptr &request : requests) camera->queueRequest(request.get()); + if (!cm->cameras().size()) { + std::cout << "No cameras were identified on the system." + << std::endl; + cm->stop(); + return EXIT_FAILURE; + } + /* * -------------------------------------------------------------------- * Run an EventLoop -- cgit v1.2.1