mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-05-28 00:30:23 -04:00
raw: LibRaw_QIODevice::read: fixed possible partial reading of an item
- If the size of an item is greater than 1 byte, it must be ensured that it is not partially read. - In many readings, LibRAW gives an error if a partial number of items are read so I always try to read everything.
This commit is contained in:
parent
361f9e867e
commit
dcab3a06ab
@ -111,10 +111,20 @@ public:
|
|||||||
}
|
}
|
||||||
virtual int read(void *ptr, size_t sz, size_t nmemb) override
|
virtual int read(void *ptr, size_t sz, size_t nmemb) override
|
||||||
{
|
{
|
||||||
auto read = m_device->read(reinterpret_cast<char *>(ptr), sz * nmemb);
|
qint64 read = 0;
|
||||||
if (read < 1) {
|
if (sz == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
auto data = reinterpret_cast<char*>(ptr);
|
||||||
|
for (qint64 r = 0, size = sz * nmemb; read < size; read += r) {
|
||||||
|
if (m_device->atEnd()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
r = m_device->read(data + read, size - read);
|
||||||
|
if (r < 1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return read / sz;
|
return read / sz;
|
||||||
}
|
}
|
||||||
virtual int eof() override
|
virtual int eof() override
|
||||||
|
Loading…
Reference in New Issue
Block a user