AssbinLoader: hardening, exception safety
Fixes potential memory leaks and crashes on malformed input.
This commit is contained in:
@@ -80,7 +80,8 @@ public:
|
||||
// -------------------------------------------------------------------
|
||||
// Read from stream
|
||||
size_t Read(void* pvBuffer, size_t pSize, size_t pCount) {
|
||||
const size_t cnt = std::min(pCount,(length-pos)/pSize),ofs = pSize*cnt;
|
||||
ai_assert(pvBuffer && pSize);
|
||||
const size_t cnt = std::min(pCount,(length-pos)/pSize), ofs = pSize*cnt;
|
||||
|
||||
memcpy(pvBuffer,buffer+pos,ofs);
|
||||
pos += ofs;
|
||||
|
||||
Reference in New Issue
Block a user