| Message ID | 20250314202943.112109-2-mzamazal@redhat.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
Hu 2025. 03. 14. 21:29 keltezéssel, Milan Zamazal írta: > 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@redhat.com> > --- This can only happen if there are at least 3 levels of options, no? And the current max is 2 levels, right? Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.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 }; > } >
Hi Barnabás, thank you for review. Barnabás Pőcze <barnabas.pocze@ideasonboard.com> writes: > Hu > > 2025. 03. 14. 21:29 keltezéssel, Milan Zamazal írta: >> 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@redhat.com> >> --- > > This can only happen if there are at least 3 levels of options, no? > And the current max is 2 levels, right? The current max is probably 2, but with the followup patches in the series, it becomes 3: --camera ... --stream ... <stream output options>. IIRC I've experienced the crash. > > Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.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 }; >> } >>
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 }; }
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@redhat.com> --- src/apps/common/options.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)