From 5db92377d61a8200ace115c1588bda05f8c1dde3 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Mon, 16 Jan 2017 16:14:18 -0500 Subject: [PATCH] =?UTF-8?q?resize=20buffer=20before=20reading,=20don?= =?UTF-8?q?=E2=80=99t=20just=20reserve=20it.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dumpobj.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dumpobj.cpp b/dumpobj.cpp index eb79471..4d4119d 100644 --- a/dumpobj.cpp +++ b/dumpobj.cpp @@ -576,7 +576,7 @@ void dump_lib(const char *name, int fd) std::vector 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);