mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-16 00:34:19 +00:00
Avoided possible arithmetic overflow in MemoryInputStream::read() for very large streams.
This commit is contained in:
parent
802a25bd97
commit
ebc47d9618
1 changed files with 10 additions and 5 deletions
|
|
@ -67,13 +67,18 @@ int MemoryInputStream::read (void* const buffer, const int howMany)
|
|||
{
|
||||
jassert (buffer != nullptr && howMany >= 0);
|
||||
|
||||
const int num = jmin (howMany, (int) (dataSize - position));
|
||||
if (num <= 0)
|
||||
if (howMany <= 0 || position >= dataSize)
|
||||
return 0;
|
||||
|
||||
memcpy (buffer, addBytesToPointer (data, position), (size_t) num);
|
||||
position += (unsigned int) num;
|
||||
return num;
|
||||
const size_t num = jmin ((size_t) howMany, dataSize - position);
|
||||
|
||||
if (num > 0)
|
||||
{
|
||||
memcpy (buffer, addBytesToPointer (data, position), num);
|
||||
position += num;
|
||||
}
|
||||
|
||||
return (int) num;
|
||||
}
|
||||
|
||||
bool MemoryInputStream::isExhausted()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue