I am fighting against a memory corruption for 2 hours and I solved it.
Not enought room was allocated in ATCmgr.cxx and auto_gui.cxx to store
strings.
Here is the patch, hoping it will solve Curt's and Michael's problems :

D:\FlightGear\cvs\FlightGear\src>cvs -z3 -q diff -u ATC/ATCmgr.cxx
Autopilot/auto_gui.cxx GUI/prop_picker.cxx
Index: ATC/ATCmgr.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/ATC/ATCmgr.cxx,v
retrieving revision 1.5
diff -u -r1.5 ATCmgr.cxx
--- ATC/ATCmgr.cxx      7 Jan 2003 13:11:00 -0000       1.5
+++ ATC/ATCmgr.cxx      19 Jan 2003 21:06:39 -0000
@@ -113,15 +113,15 @@
        char *s;

        // Option lists hardwired per ATC type
-       towerOptions[0] = new char[strlen(t0)];
+       towerOptions[0] = new char[strlen(t0)+1];
        strcpy(towerOptions[0], t0);
-       towerOptions[1] = new char[strlen(t1)];
+       towerOptions[1] = new char[strlen(t1)+1];
        strcpy(towerOptions[1], t1);
-       towerOptions[2] = new char[strlen(t2)];
+       towerOptions[2] = new char[strlen(t2)+1];
        strcpy(towerOptions[2], t2);
        towerOptions[3] = NULL;

-       approachOptions[0] = new char[strlen(a0)];
+       approachOptions[0] = new char[strlen(a0)+1];
        strcpy(approachOptions[0], a0);
        approachOptions[1] = NULL;

Index: Autopilot/auto_gui.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/Autopilot/auto_gui.cxx,v
retrieving revision 1.3
diff -u -r1.3 auto_gui.cxx
--- Autopilot/auto_gui.cxx      5 Jan 2003 00:10:36 -0000       1.3
+++ Autopilot/auto_gui.cxx      19 Jan 2003 21:06:39 -0000
@@ -722,7 +722,7 @@
         WPList = new char* [ WPListsize + 1 ];
         for (i = 0; i < globals->get_route()->size(); i++ ) {
            sprintf(WPString, "%5s %3.2flon %3.2flat",
globals->get_route()->get_waypoint(i).get_id().c_str(), globals->
get_route()->get_waypoint(i).get_target_lon(),
globals->get_route()->get_waypoint(i).get_target_lat());
-           WPList [i] = new char[ strlen(WPString) ];
+           WPList [i] = new char[ strlen(WPString)+1 ];
            strcpy ( WPList [i], WPString );
         }
     } else {
Index: GUI/prop_picker.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/GUI/prop_picker.cxx,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 prop_picker.cxx
--- GUI/prop_picker.cxx 10 Sep 2002 01:14:04 -0000      1.1.1.1
+++ GUI/prop_picker.cxx 19 Jan 2003 21:06:40 -0000
@@ -448,15 +448,15 @@
     values = new char* [ num_files+1 ] ;
     dflag = new char  [ num_files+1 ] ;
     stdString line = ".";
-    files [ 0 ] = new char[ strlen(line.c_str())+2 ];
+    files [ 0 ] = new char[ strlen(line.c_str())+1 ];
     strcpy ( files [ 0 ], line.c_str() );
     names [ 0 ] = new char[ 2 ];
     values[ 0 ] = new char[ 2 ] ;
     line = "..";
     dflag[ 0 ] = 1;
-    files [ 1 ] = new char[ strlen(line.c_str())+2 ];
+    files [ 1 ] = new char[ strlen(line.c_str())+1 ];
     strcpy ( files [ 1 ], line.c_str() );
-    names [ 1 ] = new char[ strlen(line.c_str())+2 ];
+    names [ 1 ] = new char[ strlen(line.c_str())+1 ];
     values[ 1 ] = new char[ 2 ] ;
     strcpy ( names [ 1 ], line.c_str() );

@@ -480,25 +480,25 @@
     for (i = 0; i < nChildren; i++) {
            SGPropertyNode * child = children[i];
            stdString name = child->getDisplayName(true);
-           names[ pi ] = new char[ strlen(name.c_str())+2 ] ;
+           names[ pi ] = new char[ strlen(name.c_str())+1 ] ;
            strcpy ( names [ pi ], name.c_str() ) ;
            if ( child->nChildren() > 0 ) {
                dflag[ pi ] = 1 ;
-                files[ pi ] = new char[ strlen(name.c_str())+2 ] ;
+                files[ pi ] = new char[ strlen(name.c_str())+1 ] ;
                strcpy ( files [ pi ], name.c_str() ) ;
                strcat ( files [ pi ], "/" ) ;
                values[ pi ] = new char[ 2 ] ;
            } else {
                 dflag[ pi ] = 0 ;
                stdString value = child->getStringValue();
-               values[ pi ] = new char[ strlen(value.c_str())+2 ] ;
+               values[ pi ] = new char[ strlen(value.c_str())+1 ] ;
                 strcpy ( values [pi], value.c_str() );
                stdString line = name + " = '" + value + "' " + "(";
                line += getValueTypeString( child );
                 line += ")";
                 // truncate entries to plib pui limit
                 if (line.length() > (PUSTRING_MAX-1)) line[PUSTRING_MAX-1]
= '\0';
-                files[ pi ] = new char[ strlen(line.c_str())+2 ] ;
+                files[ pi ] = new char[ strlen(line.c_str())+1 ] ;
                strcpy ( files [ pi ], line.c_str() ) ;
            }
             // printf("files->%i of %i %s\n",pi, node->nChildren(), files
[pi]);


Cheers,

-Fred



_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to