Bug 1418810 - Use fallible assign to prevent OOM. r=mayhemer
authorValentin Gosu <valentin.gosu@gmail.com>
Tue, 21 Nov 2017 20:36:01 +0100
changeset 437775 4873b451e40f08178298e0c18776b35e91d6f545
parent 437774 d811ce4ebcd9a7bfce3e6ac0ec5d006f9e2ff82c
child 437776 9bd0ee246f1ec8786617eb9bda31ff26a5a1e4fd
push id117
push userfmarier@mozilla.com
push dateTue, 28 Nov 2017 20:17:16 +0000
reviewersmayhemer
bugs1418810
milestone59.0a1
Bug 1418810 - Use fallible assign to prevent OOM. r=mayhemer MozReview-Commit-ID: LU1RbkUIBZz
netwerk/base/nsSimpleURI.cpp
--- a/netwerk/base/nsSimpleURI.cpp
+++ b/netwerk/base/nsSimpleURI.cpp
@@ -465,17 +465,19 @@ nsSimpleURI::SetPathQueryRefEscaped(cons
     nsresult rv;
     nsAutoCString path;
     if (aNeedsEscape) {
         rv = NS_EscapeURL(aPath, esc_OnlyNonASCII, path, fallible);
         if (NS_FAILED(rv)) {
           return rv;
         }
     } else {
-        path.Assign(aPath);
+        if (!path.Assign(aPath, fallible)) {
+            return NS_ERROR_OUT_OF_MEMORY;
+        }
     }
 
     int32_t queryPos = path.FindChar('?');
     int32_t hashPos = path.FindChar('#');
 
     if (queryPos != kNotFound && hashPos != kNotFound && hashPos < queryPos) {
         queryPos = kNotFound;
     }