On Sat, May 22, 2010 at 10:30 PM, Jeff Taylor <jefftaylo...@gmail.com>wrote:
> Hello, > > fgviewer crashes when reading channel options (which it doesn't use). > Here is a patch which fixes this by adding a pointer check. > > This is my first ever patch to any open source project, so feedback > would be appreciated. :) > > I've committed this; thanks for the patch. There's not much to say about the code in the patch, but I do have some advice about the comments. It's almost never necessary to justify a null pointer check, so the comment there is redundant. The comment is actually a justification for why we should accept the patch; as such, it belongs in the commit message i.e., the body of your email. The second comment about the return value not being checked is not relevant at all in this function and is quite likely to be made obsolete. I replaced it with an XXX style comment in the caller of add_channel as a reminder to look into this. Tim > Jeff Taylor > > --- > src/Main/options.cxx | 8 ++++++++ > 1 files changed, 8 insertions(+), 0 deletions(-) > > diff --git a/src/Main/options.cxx b/src/Main/options.cxx > index bededfb..0132c02 100644 > --- a/src/Main/options.cxx > +++ b/src/Main/options.cxx > @@ -530,6 +530,14 @@ parse_fov( const string& arg ) { > > static bool > add_channel( const string& type, const string& channel_str ) { > + // This check is neccessary to prevent fgviewer from segfaulting when > given > + // weird options. (It doesn't run the full initailization) > + if(globals->get_channel_options_list() == NULL) > + { > + SG_LOG(SG_GENERAL, SG_ALERT, "Option " << type << "=" << > channel_str > + << " ignored."); > + return false; // This isn't checked for, but it shouldn't matter > + } > SG_LOG(SG_GENERAL, SG_INFO, "Channel string = " << channel_str ); > globals->get_channel_options_list()->push_back( type + "," + > channel_str ); > return true; > -- > 1.7.0.1 > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Flightgear-devel mailing list > Flightgear-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/flightgear-devel >
------------------------------------------------------------------------------
_______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel