Browse Source

Fix possible crash when downloading favicons

master
Dorian 7 years ago
parent
commit
fe71ff990c
  1. 7
      k-meleon/app/FavIconList.cpp
  2. 1
      k-meleon/app/KmImage.cpp
  3. 1
      k-meleon/app/KmImage.h
  4. 6
      k-meleon/app/MozUtils.cpp

7
k-meleon/app/FavIconList.cpp

@ -485,12 +485,7 @@ bool CFavIconList::DwnFavIcon(nsIURI* iconURI, nsIURI* pageURI, bool reload)
iconURI->GetScheme(scheme);
iconObserver* io = new iconObserver(this, iconURI, pageURI);
if (!kImageObserver::LoadImage(io, iconURI)) {
delete io;
return false;
}
return true;
return kImageObserver::LoadImage(io, iconURI);
}
mozIAsyncFavicons* CFavIconList::GetIconService()

1
k-meleon/app/KmImage.cpp

@ -74,7 +74,6 @@ NS_IMETHODIMP nsImageObserver::Notify(imgIRequest *aProxy, int32_t aType, const
mObserver->ImageLoaded(img);
aProxy->CancelAndForgetObserver(NS_OK);
//mRequest = nullptr;
delete mObserver;
if (mNeedRelease) NS_RELEASE_THIS();
// Can't release here anymore else gecko crash
/*nsCOMPtr<nsIThreadManager> tm = do_GetService("@mozilla.org/thread-manager;1");

1
k-meleon/app/KmImage.h

@ -63,6 +63,7 @@ class kImageObserver : public IDownloadObserver
public:
static bool LoadImage(IImageObserver* observer, nsIURI* imgUri)
{
if (!observer) return false;
kImageObserver* obs = new kImageObserver(observer);
return DownloadToStream(imgUri, obs);
}

6
k-meleon/app/MozUtils.cpp

@ -806,6 +806,9 @@ NS_IMETHODIMP streamListener::OnStopRequest(nsIRequest *aRequest, nsISupports *a
bool DownloadToStream(nsIURI* uri, IDownloadObserver* observer)
{
NS_ENSURE_TRUE(observer, false);
nsCOMPtr<nsIStreamListener> l = new streamListener(observer);
nsresult rv;
nsCOMPtr<nsIIOService> io = do_GetService("@mozilla.org/network/io-service;1", &rv);
NS_ENSURE_SUCCESS(rv, false);
@ -813,8 +816,7 @@ bool DownloadToStream(nsIURI* uri, IDownloadObserver* observer)
nsCOMPtr<nsIChannel> channel;
io->NewChannelFromURI(uri, getter_AddRefs(channel));
NS_ENSURE_TRUE(channel, false);
nsCOMPtr<nsIStreamListener> l = new streamListener(observer);
rv = channel->AsyncOpen(l, nullptr);
return NS_SUCCEEDED(rv);
}

Loading…
Cancel
Save