From 3513af4bc0827a9a54c4de826fc95d279741e6ef Mon Sep 17 00:00:00 2001 From: Andreas Schenk <andreas_schenk@hms.harvard.edu> Date: Thu, 7 Jun 2012 15:29:31 -0400 Subject: [PATCH] properly allocate and deallocate dynamic char array in IPL io --- modules/io/src/img/map_io_ipl_handler.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/io/src/img/map_io_ipl_handler.cc b/modules/io/src/img/map_io_ipl_handler.cc index dd1fb2981..88f2c5b5a 100644 --- a/modules/io/src/img/map_io_ipl_handler.cc +++ b/modules/io/src/img/map_io_ipl_handler.cc @@ -193,9 +193,10 @@ std::ostream& operator<< (std::ostream& out, const IPLHeader& h ) out << "COMMENT = Created by OpenStructure \r\n"; out << " \r\n"; uint fillsize=h.header_length-out.tellp()+start_pos; - char empty[fillsize]; + char* empty=new char[fillsize]; std::fill_n(empty,fillsize,0); out.write(empty,fillsize); + delete[] empty; return out; } @@ -256,9 +257,10 @@ std::istream& operator>> (std::istream& in, IPLHeader& h) } }while(in.peek()!=0); 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); in.read(empty,fillsize); + delete[] empty; return in; } -- GitLab