Message ID | 20190131234721.22606-6-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Hi Laurent, Thanks for your work. On 2019-02-01 01:47:18 +0200, Laurent Pinchart wrote: > When option are added to the parser, they are stored in the > OptionsParser::options_ vector, and a pointer to the option referencing > the vector entry is indexed in the OptionsParser::optionsMap_ map. When > the next option is added the vector may be resized, which invalidates > the pointers stored in the map. > > Fix this by storing the options in an std::list<> instead of > std::vector<>. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > --- > src/cam/options.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/src/cam/options.h b/src/cam/options.h > index 2272385a0b83..b9b7bd258c03 100644 > --- a/src/cam/options.h > +++ b/src/cam/options.h > @@ -8,8 +8,8 @@ > #define __CAM_OPTIONS_H__ > > #include <ctype.h> > +#include <list> > #include <map> > -#include <vector> > > enum OptionArgument { > ArgumentNone, > @@ -57,7 +57,7 @@ public: > void usage(); > > private: > - std::vector<Option> options_; > + std::list<Option> options_; > std::map<unsigned int, Option *> optionsMap_; > }; > > -- > Regards, > > Laurent Pinchart >
diff --git a/src/cam/options.h b/src/cam/options.h index 2272385a0b83..b9b7bd258c03 100644 --- a/src/cam/options.h +++ b/src/cam/options.h @@ -8,8 +8,8 @@ #define __CAM_OPTIONS_H__ #include <ctype.h> +#include <list> #include <map> -#include <vector> enum OptionArgument { ArgumentNone, @@ -57,7 +57,7 @@ public: void usage(); private: - std::vector<Option> options_; + std::list<Option> options_; std::map<unsigned int, Option *> optionsMap_; };
When option are added to the parser, they are stored in the OptionsParser::options_ vector, and a pointer to the option referencing the vector entry is indexed in the OptionsParser::optionsMap_ map. When the next option is added the vector may be resized, which invalidates the pointers stored in the map. Fix this by storing the options in an std::list<> instead of std::vector<>. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- src/cam/options.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)