Bug 1476340: Fix DEAD_STORE errors in security/sandbox/linux/*. r=gcp
authorRobert Bartlensky <rbartlensky@mozilla.com>
Tue, 17 Jul 2018 18:30:09 +0100
changeset 427482 564e53c57905714866e727e649e79ea14cb808b3
parent 427481 a9c6b8e2e0ea933cabd5f31a5bf9250712978fd3
child 427483 ece31a9e0c0b4b97fd0a1248c0f722c591dd82e7
push id34306
push usercsabou@mozilla.com
push dateFri, 20 Jul 2018 21:41:18 +0000
treeherdermozilla-central@d6a5e8aea651 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgcp
bugs1476340
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1476340: Fix DEAD_STORE errors in security/sandbox/linux/*. r=gcp MozReview-Commit-ID: 3jNPRWGb7rU
security/sandbox/linux/SandboxOpenedFiles.cpp
security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
--- a/security/sandbox/linux/SandboxOpenedFiles.cpp
+++ b/security/sandbox/linux/SandboxOpenedFiles.cpp
@@ -33,17 +33,17 @@ SandboxOpenedFile::SandboxOpenedFile(con
     mExpectError = true;
   }
   mMaybeFd = fd;
 }
 
 int
 SandboxOpenedFile::GetDesc() const
 {
-  int fd = -1;
+  int fd;
   if (mDup) {
     fd = mMaybeFd;
     if (fd >= 0) {
       fd = dup(fd);
       if (fd < 0) {
         SANDBOX_LOG_ERROR("dup: %s", strerror(errno));
       }
     }
--- a/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
+++ b/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
@@ -120,16 +120,19 @@ AddPathsFromFile(SandboxBroker::Policy* 
   nsCOMPtr<nsILineInputStream> lineStream(do_QueryInterface(fileStream, &rv));
   if (NS_FAILED(rv)) {
     return;
   }
   nsAutoCString line;
   bool more = true;
   do {
     rv = lineStream->ReadLine(line, &more);
+    if (NS_FAILED(rv)) {
+      break;
+    }
     // Cut off any comments at the end of the line, also catches lines
     // that are entirely a comment
     int32_t hash = line.FindChar('#');
     if (hash >= 0) {
       line = Substring(line, 0, hash);
     }
     // Simplify our following parsing by trimming whitespace
     line.CompressWhitespace(true, true);