mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-06-03 17:08:08 -04:00
LibRaw_QIODevice::seek() bounding checks
This commit is contained in:
parent
65a20b43fc
commit
d881a7bbb1
@ -131,11 +131,15 @@ public:
|
|||||||
virtual int seek(INT64 o, int whence) override
|
virtual int seek(INT64 o, int whence) override
|
||||||
{
|
{
|
||||||
auto pos = o;
|
auto pos = o;
|
||||||
|
auto size = m_device->size();
|
||||||
if (whence == SEEK_CUR) {
|
if (whence == SEEK_CUR) {
|
||||||
pos = m_device->pos() + o;
|
pos = m_device->pos() + o;
|
||||||
}
|
}
|
||||||
if (whence == SEEK_END) {
|
if (whence == SEEK_END) {
|
||||||
pos = m_device->size() + o;
|
pos = size + o;
|
||||||
|
}
|
||||||
|
if (pos < 0 || pos > size) {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
return m_device->seek(pos) ? 0 : -1;
|
return m_device->seek(pos) ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user