Bug 774599 - Crash when content of unknown MIME type is encountered [r=jlebar]

This commit is contained in:
Fabrice Desré 2012-09-16 09:15:24 -07:00
Родитель 464976376b
Коммит 535bffe1fc
1 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -15,6 +15,16 @@
*/
#include "nsOSHelperAppService.h"
#include "nsMIMEInfoImpl.h"
// Simplest nsIMIMEInfo implementation possible.
// We don't need it to actually do anything.
class nsGonkMIMEInfo : public nsMIMEInfoImpl {
protected:
virtual NS_HIDDEN_(nsresult) LoadUriInternal(nsIURI *aURI) {
return NS_ERROR_NOT_IMPLEMENTED;
}
};
nsOSHelperAppService::nsOSHelperAppService() : nsExternalHelperAppService()
{
@ -30,7 +40,10 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aMIMEType,
bool* aFound)
{
*aFound = false;
return nullptr;
// Even if we return false for aFound, we need to return a non-null
// nsIMIMEInfo implementation to prevent a crash in the caller.
nsRefPtr<nsGonkMIMEInfo> mimeInfo = new nsGonkMIMEInfo();
return mimeInfo.forget();
}
nsresult