Core/File: Fix crash

Former-commit-id: ee797ea7ba228fa814f2c87250c6dd6c32a9982f
This commit is contained in:
Lynix 2015-11-17 14:05:46 +01:00
parent 131d047517
commit a1bb104255
2 changed files with 7 additions and 5 deletions

View File

@ -102,7 +102,6 @@ namespace Nz
Endianness m_endianness;
String m_filePath;
UInt32 m_openMode;
FileImpl* m_impl;
};

View File

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