Bug 1156255 - Make fallible a potentially large allocation in nsSimpleURI::SetPath. r=dholbert.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 01 Aug 2016 09:13:29 +1000
changeset 333348 fc636e1c960864300a847b3eaadf0143e0a7f628
parent 333347 4d9e76e287a60bf1b8ace3eb92d7cf89abfc4831
child 333349 232d6b6ae7908041cdb09fff963990a1503d63d8
push id10033
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:50:26 +0000
treeherdermozilla-aurora@5dddbefdf759 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1156255
milestone50.0a1
Bug 1156255 - Make fallible a potentially large allocation in nsSimpleURI::SetPath. r=dholbert.
netwerk/base/nsSimpleURI.cpp
--- a/netwerk/base/nsSimpleURI.cpp
+++ b/netwerk/base/nsSimpleURI.cpp
@@ -354,17 +354,19 @@ NS_IMETHODIMP
 nsSimpleURI::SetPath(const nsACString &path)
 {
     NS_ENSURE_STATE(mMutable);
     
     int32_t hashPos = path.FindChar('#');
     if (hashPos < 0) {
         mIsRefValid = false;
         mRef.Truncate(); // invariant: mRef should be empty when it's not valid
-        mPath = path;
+        if (!mPath.Assign(path, fallible)) {
+            return NS_ERROR_OUT_OF_MEMORY;
+        }
         return NS_OK;
     }
 
     mPath = StringHead(path, hashPos);
     return SetRef(Substring(path, uint32_t(hashPos)));
 }
 
 NS_IMETHODIMP