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.
This commit is contained in:
Marek Roszko 2020-12-12 10:00:49 -05:00
parent 67d8af4a4f
commit b4e4e1cf5e
1 changed files with 3 additions and 1 deletions

View File

@ -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() ) )
{