Browse Source

Use wxFFile instead of wxFile for saving json settings/json_settings.cpp

wxFile is dangerous, it's ::Write method is a direct map to the write syscall. It does not handle partial writes!
This must be handled in our code which we don't.
6.0.7
Marek Roszko 5 years ago
parent
commit
b4e4e1cf5e
  1. 4
      common/settings/json_settings.cpp

4
common/settings/json_settings.cpp

@ -33,6 +33,8 @@
#include <wx/debug.h>
#include <wx/fileconf.h>
#include <wx/filename.h>
#include <wx/ffile.h>
const wxChar* const traceSettings = wxT( "KICAD_SETTINGS" );
@ -390,7 +392,7 @@ bool JSON_SETTINGS::SaveToFile( const wxString& aDirectory, bool aForce )
std::stringstream buffer;
buffer << std::setw( 2 ) << *this << std::endl;
wxFile file( path.GetFullPath(), wxFile::write );
wxFFile file( path.GetFullPath(), "wb" );
if( !file.IsOpened() || !file.Write( buffer.str().c_str(), buffer.str().size() ) )
{

Loading…
Cancel
Save