summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ragnatech.se>2019-06-10 13:43:48 +0200
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2019-06-10 23:05:04 +0200
commit238919be5949a0bc632920cbd5b58cc4a5ca4678 (patch)
tree1dc3f0240fbf7990c2c08d69370145270288e752
parent33534000275020cacaeddde6bee7f98377bf1170 (diff)
cam: Fix cam --help crash
The cam utility does not terminate correctly if invoked with only --help. It prints the help information and then segfaults due to the application incorrectly handling the return value. Fix this by moving the return code check of the option parsing to main(). Reported-by: Emmanuel Arias <eamanu@eamanu.com> Suggested-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--src/cam/main.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/cam/main.cpp b/src/cam/main.cpp
index dbf04917..f03a9faf 100644
--- a/src/cam/main.cpp
+++ b/src/cam/main.cpp
@@ -61,7 +61,7 @@ int CamApp::init(int argc, char **argv)
ret = parseOptions(argc, argv);
if (ret < 0)
- return ret == -EINTR ? 0 : ret;
+ return ret;
cm_ = CameraManager::instance();
@@ -193,9 +193,11 @@ void signalHandler(int signal)
int main(int argc, char **argv)
{
CamApp app;
+ int ret;
- if (app.init(argc, argv))
- return EXIT_FAILURE;
+ ret = app.init(argc, argv);
+ if (ret)
+ return ret == -EINTR ? 0 : EXIT_FAILURE;
struct sigaction sa = {};
sa.sa_handler = &signalHandler;