From a1bb10425517eb58085b2f635976bb576c610c2f Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 17 Nov 2015 14:05:46 +0100 Subject: [PATCH] Core/File: Fix crash Former-commit-id: ee797ea7ba228fa814f2c87250c6dd6c32a9982f --- include/Nazara/Core/File.hpp | 1 - src/Nazara/Core/File.cpp | 11 +++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/Nazara/Core/File.hpp b/include/Nazara/Core/File.hpp index d6a819c9f..d95a5857c 100644 --- a/include/Nazara/Core/File.hpp +++ b/include/Nazara/Core/File.hpp @@ -102,7 +102,6 @@ namespace Nz Endianness m_endianness; String m_filePath; - UInt32 m_openMode; FileImpl* m_impl; }; diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index 8e3841866..8cf59b3d2 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -55,8 +55,7 @@ namespace Nz OutputStream(std::move(file)), m_endianness(file.m_endianness), m_filePath(std::move(file.m_filePath)), - m_impl(file.m_impl), - m_openMode(file.m_openMode) + m_impl(file.m_impl) { file.m_impl = nullptr; } @@ -382,17 +381,21 @@ namespace Nz NazaraAssert(IsOpen(), "File is not opened"); NazaraAssert(IsWritable(), "File not opened with write access"); - if (!buffer || size == 0) + if (size == 0) return 0; + NazaraAssert(buffer, "Invalid buffer"); + return m_impl->Write(buffer, size); } std::size_t File::Write(const void* buffer, std::size_t typeSize, unsigned int count) { - if (!buffer || count == 0 || typeSize == 0) + if (count == 0 || typeSize == 0) return 0; + NazaraAssert(buffer, "Invalid buffer"); + NazaraLock(m_mutex) if (m_endianness != Endianness_Unknown && m_endianness != GetPlatformEndianness() && typeSize != 1)