[RFC PATCH 1/7] apps: common: Fix flipped error condition
Milan Zamazal
mzamazal at redhat.com
Fri Mar 14 21:29:29 CET 2025
When OptionsParser::childOption encounters an error, it returns nullptr
and the corresponding option. The check for a nested parent checks for
an error erroneously, leading not only to a wrong behaviour in case
there's no error but also to a segmentation error in case of error due
to `options' being set to nullptr and accessed later.
Signed-off-by: Milan Zamazal <mzamazal at redhat.com>
---
src/apps/common/options.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/apps/common/options.cpp b/src/apps/common/options.cpp
index cae193cc..29a5d9c7 100644
--- a/src/apps/common/options.cpp
+++ b/src/apps/common/options.cpp
@@ -1095,7 +1095,7 @@ OptionsParser::childOption(const Option *parent, Options *options)
std::tie(options, error) = childOption(parent->parent, options);
/* Propagate the error all the way back up the call stack. */
- if (!error)
+ if (error)
return { options, error };
}
--
2.48.1
More information about the libcamera-devel
mailing list