Skip to content

Commit

Permalink
Add an assertion check in readAll
Browse files Browse the repository at this point in the history
If the assertion could fail somehow, we could have memory unsafety.
  • Loading branch information
rprichard committed Jan 4, 2017
1 parent 91fce49 commit 9f0d7e6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libwinpty/winpty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9f0d7e6

Please sign in to comment.