Core/File: Fix crash
Former-commit-id: ee797ea7ba228fa814f2c87250c6dd6c32a9982f
This commit is contained in:
parent
131d047517
commit
a1bb104255
|
|
@ -102,7 +102,6 @@ namespace Nz
|
||||||
|
|
||||||
Endianness m_endianness;
|
Endianness m_endianness;
|
||||||
String m_filePath;
|
String m_filePath;
|
||||||
UInt32 m_openMode;
|
|
||||||
FileImpl* m_impl;
|
FileImpl* m_impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,7 @@ namespace Nz
|
||||||
OutputStream(std::move(file)),
|
OutputStream(std::move(file)),
|
||||||
m_endianness(file.m_endianness),
|
m_endianness(file.m_endianness),
|
||||||
m_filePath(std::move(file.m_filePath)),
|
m_filePath(std::move(file.m_filePath)),
|
||||||
m_impl(file.m_impl),
|
m_impl(file.m_impl)
|
||||||
m_openMode(file.m_openMode)
|
|
||||||
{
|
{
|
||||||
file.m_impl = nullptr;
|
file.m_impl = nullptr;
|
||||||
}
|
}
|
||||||
|
|
@ -382,17 +381,21 @@ namespace Nz
|
||||||
NazaraAssert(IsOpen(), "File is not opened");
|
NazaraAssert(IsOpen(), "File is not opened");
|
||||||
NazaraAssert(IsWritable(), "File not opened with write access");
|
NazaraAssert(IsWritable(), "File not opened with write access");
|
||||||
|
|
||||||
if (!buffer || size == 0)
|
if (size == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
NazaraAssert(buffer, "Invalid buffer");
|
||||||
|
|
||||||
return m_impl->Write(buffer, size);
|
return m_impl->Write(buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t File::Write(const void* buffer, std::size_t typeSize, unsigned int count)
|
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;
|
return 0;
|
||||||
|
|
||||||
|
NazaraAssert(buffer, "Invalid buffer");
|
||||||
|
|
||||||
NazaraLock(m_mutex)
|
NazaraLock(m_mutex)
|
||||||
|
|
||||||
if (m_endianness != Endianness_Unknown && m_endianness != GetPlatformEndianness() && typeSize != 1)
|
if (m_endianness != Endianness_Unknown && m_endianness != GetPlatformEndianness() && typeSize != 1)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue