diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp
index 99101f200783..44a83475f0eb 100644
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -979,9 +979,9 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
}
if (isPostPage && muCV && kCharsetFromHintPrevDoc > charsetSource) {
- PRUnichar* requestCharset;
- muCV->GetPrevDocCharacterSet(&requestCharset);
- if (*requestCharset) {
+ nsXPIDLString requestCharset;
+ muCV->GetPrevDocCharacterSet(getter_Copies(requestCharset));
+ if (!requestCharset.IsEmpty()) {
charsetSource = kCharsetFromHintPrevDoc;
charset = requestCharset;
}