resize buffer before reading, don’t just reserve it.

This commit is contained in:
Kelvin Sherlock 2017-01-16 16:14:18 -05:00
parent 8ba832d9a9
commit 5db92377d6

View File

@ -576,7 +576,7 @@ void dump_lib(const char *name, int fd)
std::vector<uint8_t> data;
long count = h.l_modstart - sizeof(h);
if (count < 0) errx(EX_DATAERR, "%s", name);
data.reserve(count);
data.resize(count);
ok = read(fd, data.data(), count);
if (ok != count) errx(EX_DATAERR, "%s truncated", name);