Skip to content
Snippets Groups Projects
Commit 3513af4b authored by Andreas Schenk's avatar Andreas Schenk
Browse files

properly allocate and deallocate dynamic char array in IPL io

parent 9c34418d
Branches
Tags
No related merge requests found
...@@ -193,9 +193,10 @@ std::ostream& operator<< (std::ostream& out, const IPLHeader& h ) ...@@ -193,9 +193,10 @@ std::ostream& operator<< (std::ostream& out, const IPLHeader& h )
out << "COMMENT = Created by OpenStructure \r\n"; out << "COMMENT = Created by OpenStructure \r\n";
out << " \r\n"; out << " \r\n";
uint fillsize=h.header_length-out.tellp()+start_pos; uint fillsize=h.header_length-out.tellp()+start_pos;
char empty[fillsize]; char* empty=new char[fillsize];
std::fill_n(empty,fillsize,0); std::fill_n(empty,fillsize,0);
out.write(empty,fillsize); out.write(empty,fillsize);
delete[] empty;
return out; return out;
} }
...@@ -256,9 +257,10 @@ std::istream& operator>> (std::istream& in, IPLHeader& h) ...@@ -256,9 +257,10 @@ std::istream& operator>> (std::istream& in, IPLHeader& h)
} }
}while(in.peek()!=0); }while(in.peek()!=0);
uint fillsize=h.header_length-in.tellg()+start_pos; uint fillsize=h.header_length-in.tellg()+start_pos;
char empty[h.header_length]; char* empty=new char[h.header_length];
std::fill_n(empty,fillsize,0); std::fill_n(empty,fillsize,0);
in.read(empty,fillsize); in.read(empty,fillsize);
delete[] empty;
return in; return in;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment