diff options
author | Julian Andres Klode <jak@debian.org> | 2015-12-19 13:07:12 +0100 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2015-12-19 13:13:02 +0100 |
commit | 39e77e45ae627165a8f89d83a8f875251920ce05 (patch) | |
tree | ac424004186649cb4a3372e0352c5f0db2daf8bb | |
parent | 5df91bc70aeac9f39f33d748a3b5602fbf2a3e81 (diff) |
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
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 5 |
1 files changed, 2 insertions, 3 deletions
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; |