diff --git a/browser/components/feeds/src/nsFeedSniffer.cpp b/browser/components/feeds/src/nsFeedSniffer.cpp index 2c5602553586..5ee58b07d875 100644 --- a/browser/components/feeds/src/nsFeedSniffer.cpp +++ b/browser/components/feeds/src/nsFeedSniffer.cpp @@ -69,7 +69,7 @@ #define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#" #define NS_RSS "http://purl.org/rss/1.0/" -#define MAX_BYTES 512 +#define MAX_BYTES 512u NS_IMPL_ISUPPORTS3(nsFeedSniffer, nsIContentSniffer, @@ -324,8 +324,9 @@ nsFeedSniffer::GetMIMETypeFromContent(nsIRequest* request, // We cap the number of bytes to scan at MAX_BYTES to prevent picking up // false positives by accidentally reading document content, e.g. a "how to // make a feed" page. - if (length > MAX_BYTES) - length = MAX_BYTES; + if (!mDecodedData.IsEmpty()) { + length = NS_MIN(mDecodedData.Length(), MAX_BYTES); + } // Thus begins the actual sniffing. nsDependentCSubstring dataString((const char*)testData, length);