diff options
author | Umang Jain <email@uajain.com> | 2020-12-04 12:24:50 +0530 |
---|---|---|
committer | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2020-12-04 10:28:11 +0000 |
commit | 14529b6d1c4a6d405b23157eca8a4b0bec632e00 (patch) | |
tree | ba54c1656230f89a416a83abda49d3b29638e48e /simple-cam.cpp | |
parent | e6663c0f8c86305acfc9562f75c11b75356a67ec (diff) |
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 <email@uajain.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'simple-cam.cpp')
-rw-r--r-- | simple-cam.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
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> &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 |