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. :)

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

Reply via email to