diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2023-02-21 19:40:57 +0100 |
---|---|---|
committer | Christian Göttsche <cgzones@googlemail.com> | 2023-02-21 19:40:57 +0100 |
commit | c00676a28af82f4c73c19916b803d7058f02d104 (patch) | |
tree | 7480adb23f817aec7c574f521710d3d048d65ff4 | |
parent | a3934549633550ea625604c03e25724664048f40 (diff) | |
download | patchelf-c00676a28af82f4c73c19916b803d7058f02d104.tar.gz |
Close file before potentially throwing
-rw-r--r-- | src/patchelf.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/patchelf.cc b/src/patchelf.cc index 946e81c..8240361 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -196,11 +196,11 @@ static FileContents readFile(const std::string & fileName, while ((portion = read(fd, contents->data() + bytesRead, size - bytesRead)) > 0) bytesRead += portion; + close(fd); + if (bytesRead != size) throw SysError(fmt("reading '", fileName, "'")); - close(fd); - return contents; } |