diff --git a/src/Objects/matlib.cxx b/src/Objects/matlib.cxx index 55a6b25db..6c8cf6b7f 100644 --- a/src/Objects/matlib.cxx +++ b/src/Objects/matlib.cxx @@ -130,8 +130,14 @@ bool FGMaterialLib::load( const string& mpath ) { in >> token; if ( token == '{' ) { + // Read the data into a temporary but stack allocated + // copy of the structure + FGNewMat tmp; + in >> tmp; + + // create a pointer to a heap allocated copy of the structure FGNewMat *m = new FGNewMat; - in >> *m; + *m = tmp; // build the ssgSimpleState SGPath tex_path( globals->get_fg_root() ); diff --git a/src/Objects/newmat.cxx b/src/Objects/newmat.cxx index 2fa702d61..1e917524d 100644 --- a/src/Objects/newmat.cxx +++ b/src/Objects/newmat.cxx @@ -200,7 +200,6 @@ void FGNewMat::dump_info () { FGNewMat::~FGNewMat ( void ) { } - istream& operator >> ( istream& in, FGNewMat& m ) {