Check lock before creating the copy, as suggested by Yoran.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2501 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
72d4a362db
commit
b0e11dbd13
@ -1383,14 +1383,18 @@ IImage* CNullDriver::createImage(ITexture* texture, const core::position2d<s32>&
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// make sure to avoid buffer overruns
|
// make sure to avoid buffer overruns
|
||||||
const core::rect<u32> clamped(core::vector2d<u32>(core::clamp(static_cast<u32>(pos.X), 0u, texture->getSize().Width),
|
// make the vector a separate variable for g++ 3.x
|
||||||
core::clamp(static_cast<u32>(pos.Y), 0u, texture->getSize().Height)),
|
const core::vector2d<u32> leftUpper(core::clamp(static_cast<u32>(pos.X), 0u, texture->getSize().Width),
|
||||||
|
core::clamp(static_cast<u32>(pos.Y), 0u, texture->getSize().Height));
|
||||||
|
const core::rect<u32> clamped(leftUpper,
|
||||||
core::dimension2du(core::clamp(static_cast<u32>(size.Width), 0u, texture->getSize().Width),
|
core::dimension2du(core::clamp(static_cast<u32>(size.Width), 0u, texture->getSize().Width),
|
||||||
core::clamp(static_cast<u32>(size.Height), 0u, texture->getSize().Height)));
|
core::clamp(static_cast<u32>(size.Height), 0u, texture->getSize().Height)));
|
||||||
if (!clamped.isValid())
|
if (!clamped.isValid())
|
||||||
return 0;
|
return 0;
|
||||||
IImage* image = new CImage(texture->getColorFormat(), clamped.getSize());
|
|
||||||
void* src = texture->lock(true);
|
void* src = texture->lock(true);
|
||||||
|
if (!src)
|
||||||
|
return 0;
|
||||||
|
IImage* image = new CImage(texture->getColorFormat(), clamped.getSize());
|
||||||
void* dst = image->lock();
|
void* dst = image->lock();
|
||||||
for (u32 i=clamped.UpperLeftCorner.X; i<clamped.getHeight(); ++i)
|
for (u32 i=clamped.UpperLeftCorner.X; i<clamped.getHeight(); ++i)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user