Properly terminate source file data.

This commit is contained in:
Bartosz Taudul 2018-12-16 19:48:34 +01:00
parent 80bd4275eb
commit ff8c9ab6dc

View File

@ -395,9 +395,10 @@ void View::SetTextEditorFile( const char* fileName, int line )
fseek( f, 0, SEEK_END ); fseek( f, 0, SEEK_END );
const auto sz = ftell( f ); const auto sz = ftell( f );
fseek( f, 0, SEEK_SET ); fseek( f, 0, SEEK_SET );
auto data = new char[sz]; auto data = new char[sz+1];
fread( data, 1, sz, f ); fread( data, 1, sz, f );
fclose( f ); fclose( f );
data[sz] = '\0';
m_textEditor->SetText( data ); m_textEditor->SetText( data );
delete[] data; delete[] data;
} }