summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2023-02-21 19:40:57 +0100
committerChristian Göttsche <cgzones@googlemail.com>2023-02-21 19:40:57 +0100
commitc00676a28af82f4c73c19916b803d7058f02d104 (patch)
tree7480adb23f817aec7c574f521710d3d048d65ff4
parenta3934549633550ea625604c03e25724664048f40 (diff)
downloadpatchelf-c00676a28af82f4c73c19916b803d7058f02d104.tar.gz
Close file before potentially throwing
-rw-r--r--src/patchelf.cc4
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;
}