mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 10:20:48 +00:00
Fix crash recovering sessions from v1.2.9 or older
The issue here was the missing color space was allocating an huge std::vector() because we had an invalid color space size from read32().
This commit is contained in:
parent
ae40198106
commit
2550e28c83
@ -343,14 +343,18 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read color space
|
// Read color space
|
||||||
gfx::ColorSpacePtr colorSpace = readColorSpace(s);
|
if (!s.eof()) {
|
||||||
if (colorSpace)
|
gfx::ColorSpacePtr colorSpace = readColorSpace(s);
|
||||||
spr->setColorSpace(colorSpace);
|
if (colorSpace)
|
||||||
|
spr->setColorSpace(colorSpace);
|
||||||
|
}
|
||||||
|
|
||||||
// Read grid bounds
|
// Read grid bounds
|
||||||
gfx::Rect gridBounds = readGridBounds(s);
|
if (!s.eof()) {
|
||||||
if (!gridBounds.isEmpty())
|
gfx::Rect gridBounds = readGridBounds(s);
|
||||||
spr->setGridBounds(gridBounds);
|
if (!gridBounds.isEmpty())
|
||||||
|
spr->setGridBounds(gridBounds);
|
||||||
|
}
|
||||||
|
|
||||||
return spr.release();
|
return spr.release();
|
||||||
}
|
}
|
||||||
@ -360,6 +364,12 @@ private:
|
|||||||
const gfx::ColorSpace::Flag flags = (gfx::ColorSpace::Flag)read16(s);
|
const gfx::ColorSpace::Flag flags = (gfx::ColorSpace::Flag)read16(s);
|
||||||
const double gamma = fixmath::fixtof(read32(s));
|
const double gamma = fixmath::fixtof(read32(s));
|
||||||
const size_t n = read32(s);
|
const size_t n = read32(s);
|
||||||
|
|
||||||
|
// If the color space file is to big, it's because the sprite file
|
||||||
|
// is invalid or or from an old session without color spcae.
|
||||||
|
if (n > 1024*1024*64) // 64 MB is too much for an ICC file
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
std::vector<uint8_t> buf(n);
|
std::vector<uint8_t> buf(n);
|
||||||
if (n)
|
if (n)
|
||||||
s.read((char*)&buf[0], n);
|
s.read((char*)&buf[0], n);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user