From 39e77e45ae627165a8f89d83a8f875251920ce05 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 19 Dec 2015 13:07:12 +0100 Subject: Do not try to read in FileFd::Read() if Size is 0 There's no point trying to read 0 bytes, so let's just not do this and switch to a while loop like in Write(). Gbp-Dch: ignore --- apt-pkg/contrib/fileutl.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 0d1c272ab..c906a0c9e 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1506,12 +1506,12 @@ FileFd::~FileFd() gracefully. */ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual) { - ssize_t Res; + ssize_t Res = 1; errno = 0; if (Actual != 0) *Actual = 0; *((char *)To) = '\0'; - do + while (Res > 0 && Size > 0) { if (false) /* dummy so that the rest can be 'else if's */; @@ -1605,7 +1605,6 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual) if (Actual != 0) *Actual += Res; } - while (Res > 0 && Size > 0); if (Size == 0) return true; -- cgit v1.2.3