diff --git a/mozilla/xpcom/io/nsLocalFileUnicode.cpp b/mozilla/xpcom/io/nsLocalFileUnicode.cpp index c494463d736..e87a1b996ad 100644 --- a/mozilla/xpcom/io/nsLocalFileUnicode.cpp +++ b/mozilla/xpcom/io/nsLocalFileUnicode.cpp @@ -231,6 +231,13 @@ nsFSStringConversion::UCSToNewFS( const PRUnichar* aIn, char** aOut) { PRInt32 inLength = nsCRT::strlen(aIn); PRInt32 outLength; + // Need to clear up the buffer because a encoder returning + // NS_OK_UDEC_MOREINPUT for an unconvertable aIn lead a new + // file name in aIn to be _appended_ to the end of the encoder buffer. + // (bug 133216 and bug 131161) + res= mEncoder->Reset(); + if(NS_FAILED(res)) + return res; res= mEncoder->GetMaxLength(aIn, inLength,&outLength); if(NS_SUCCEEDED(res)) { *aOut = (char*)nsMemory::Alloc(outLength+1); @@ -260,6 +267,13 @@ nsFSStringConversion::FSToNewUCS( const char* aIn, PRUnichar** aOut) { PRInt32 inLength = strlen(aIn); PRInt32 outLength; + // Need to clear up the buffer because a decoder returning + // NS_OK_UDEC_MOREINPUT for an unconvertable aIn lead a new + // file name in aIn to be _appended_ to the end of the decoder buffer. + // (bug 133216 and bug 131161) + res= mDecoder->Reset(); + if(NS_FAILED(res)) + return res; res= mDecoder->GetMaxLength(aIn, inLength,&outLength); if(NS_SUCCEEDED(res)) { *aOut = (PRUnichar*)nsMemory::Alloc(2*(outLength+1)); diff --git a/mozilla/xpfe/components/filepicker/src/nsFileView.cpp b/mozilla/xpfe/components/filepicker/src/nsFileView.cpp index 6fb83a39228..da939acfb0f 100644 --- a/mozilla/xpfe/components/filepicker/src/nsFileView.cpp +++ b/mozilla/xpfe/components/filepicker/src/nsFileView.cpp @@ -649,7 +649,10 @@ nsFileView::FilterFiles() file->IsHidden(&isHidden); nsXPIDLString unicodeLeafName; - file->GetUnicodeLeafName(getter_Copies(unicodeLeafName)); + if(NS_FAILED(file->GetUnicodeLeafName(getter_Copies(unicodeLeafName)))) { + // need to check return value for GetUnicodeLeafName() + continue; + } if (!isHidden) { for (PRInt32 j = 0; j < filterCount; ++j) {