From bbba00cf859569c3026ca069160ede5ec74f6edc Mon Sep 17 00:00:00 2001 From: "kyle.yuan%sun.com" Date: Thu, 13 May 2004 07:21:12 +0000 Subject: [PATCH] Bug 242990 Crash when LDAP query results content none UTF8 characters r+sr=dmose, patch by wind.li@sun.com --- directory/xpcom/base/src/nsLDAPMessage.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/directory/xpcom/base/src/nsLDAPMessage.cpp b/directory/xpcom/base/src/nsLDAPMessage.cpp index e6f908d4a6c..dfbe6cf5277 100644 --- a/directory/xpcom/base/src/nsLDAPMessage.cpp +++ b/directory/xpcom/base/src/nsLDAPMessage.cpp @@ -518,7 +518,11 @@ nsLDAPMessage::GetValues(const char *aAttr, PRUint32 *aCount, // PRUint32 i; for ( i = 0 ; i < numVals ; i++ ) { - (*aValues)[i] = UTF8ToNewUnicode(nsDependentCString(values[i])); + nsDependentCString sValue(values[i]); + if (IsUTF8(sValue)) + (*aValues)[i] = UTF8ToNewUnicode(sValue); + else + (*aValues)[i] = ToNewUnicode(sValue); if ( ! (*aValues)[i] ) { NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(i, aValues); ldap_value_free(values);