Add an assertion check in readAll
If the assertion could fail somehow, we could have memory unsafety.
This commit is contained in:
parent
91fce49ab1
commit
9f0d7e6b4e
@ -342,7 +342,8 @@ static size_t readData(winpty_t &wp, void *data, size_t amount) {
|
||||
|
||||
static void readAll(winpty_t &wp, void *data, size_t amount) {
|
||||
while (amount > 0) {
|
||||
size_t chunk = readData(wp, data, amount);
|
||||
const size_t chunk = readData(wp, data, amount);
|
||||
ASSERT(chunk <= amount && "readData result is larger than amount");
|
||||
data = reinterpret_cast<char*>(data) + chunk;
|
||||
amount -= chunk;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user