Bug 1346419 - Bail out on zero length data. r=valentin a=gchang
authorDaniel Stenberg <daniel@haxx.se>
Wed, 22 Mar 2017 10:08:47 +0100
changeset 379393 39bd60385e7475126c9655dd2ecd5648e5161ce5
parent 379392 a299db599d974d5b42be6b252e6d6682a59c6273
child 379394 29e4712df62fe6eefa1958cce98819424d611a79
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin, gchang
bugs1346419
milestone53.0
Bug 1346419 - Bail out on zero length data. r=valentin a=gchang Since we cannot call .First() on it and since it clearly contains nothing to show anyway!
netwerk/streamconv/converters/nsIndexedToHTML.cpp
--- a/netwerk/streamconv/converters/nsIndexedToHTML.cpp
+++ b/netwerk/streamconv/converters/nsIndexedToHTML.cpp
@@ -698,16 +698,20 @@ nsIndexedToHTML::OnIndexAvailable(nsIReq
 
     // We don't know the file's character set yet, so retrieve the raw bytes
     // which will be decoded by the HTML parser.
     nsXPIDLCString loc;
     aIndex->GetLocation(getter_Copies(loc));
 
     // Adjust the length in case unescaping shortened the string.
     loc.Truncate(nsUnescapeCount(loc.BeginWriting()));
+
+    if (loc.IsEmpty()) {
+        return NS_ERROR_ILLEGAL_VALUE;
+    }
     if (loc.First() == char16_t('.'))
         pushBuffer.AppendLiteral(" class=\"hidden-object\"");
 
     pushBuffer.AppendLiteral(">\n <td sortable-data=\"");
 
     // The sort key is the name of the item, prepended by either 0, 1 or 2
     // in order to group items.
     uint32_t type;