Bug 1476340: Fix DEAD_STORE errors in security/sandbox/linux/*. r?gcp draft
authorRobert Bartlensky <rbartlensky@mozilla.com>
Tue, 17 Jul 2018 18:30:09 +0100
changeset 820282 c3f3418358570820674a3e7f2020fe94cb4e7195
parent 820131 5a8107262015714d2907a85abc24c847ad9b32d2
push id116785
push userbmo:rbartlensky@mozilla.com
push dateThu, 19 Jul 2018 11:54:59 +0000
reviewersgcp
bugs1476340
milestone63.0a1
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);