diff --git a/xpcom/ds/nsCRT.cpp b/xpcom/ds/nsCRT.cpp index 3d50280dc7f4..6179944e0d88 100644 --- a/xpcom/ds/nsCRT.cpp +++ b/xpcom/ds/nsCRT.cpp @@ -273,6 +273,8 @@ PRUint32 nsCRT::HashCode(const char* str, PRUint32* resultingStrLen) PRUint32 h = 0; const char* s = str; + if (!str) return h; + unsigned char c; while ( (c = *s++) ) h = (h>>28) ^ (h<<4) ^ c; @@ -287,6 +289,8 @@ PRUint32 nsCRT::HashCode(const PRUnichar* str, PRUint32* resultingStrLen) PRUint32 h = 0; const PRUnichar* s = str; + if (!str) return h; + { PRUint16 W1 = 0; // the first UTF-16 word in a two word tuple PRUint32 U = 0; // the current char as UCS-4