mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 750983 - ICO crash [mozilla::image::Decoder::Write]. r=joe
This commit is contained in:
parent
2189b074a3
commit
6032eaea96
@ -365,9 +365,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
|
||||
if (mIsPNG) {
|
||||
mContainedDecoder = new nsPNGDecoder(mImage, mObserver);
|
||||
mContainedDecoder->InitSharedDecoder();
|
||||
mContainedDecoder->Write(mSignature, PNGSIGNATURESIZE);
|
||||
mDataError = mContainedDecoder->HasDataError();
|
||||
if (mContainedDecoder->HasDataError()) {
|
||||
if (!WriteToContainedDecoder(mSignature, PNGSIGNATURESIZE)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -375,9 +373,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
|
||||
|
||||
// If we have a PNG, let the PNG decoder do all of the rest of the work
|
||||
if (mIsPNG && mContainedDecoder && mPos >= mImageOffset + PNGSIGNATURESIZE) {
|
||||
mContainedDecoder->Write(aBuffer, aCount);
|
||||
mDataError = mContainedDecoder->HasDataError();
|
||||
if (mContainedDecoder->HasDataError()) {
|
||||
if (!WriteToContainedDecoder(aBuffer, aCount)) {
|
||||
return;
|
||||
}
|
||||
mPos += aCount;
|
||||
@ -445,9 +441,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
|
||||
PostDataError();
|
||||
return;
|
||||
}
|
||||
mContainedDecoder->Write((const char*)bfhBuffer, sizeof(bfhBuffer));
|
||||
mDataError = mContainedDecoder->HasDataError();
|
||||
if (mContainedDecoder->HasDataError()) {
|
||||
if (!WriteToContainedDecoder((const char*)bfhBuffer, sizeof(bfhBuffer))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -468,9 +462,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
|
||||
}
|
||||
|
||||
// Write out the BMP's bitmap info header
|
||||
mContainedDecoder->Write(mBIHraw, sizeof(mBIHraw));
|
||||
mDataError = mContainedDecoder->HasDataError();
|
||||
if (mContainedDecoder->HasDataError()) {
|
||||
if (!WriteToContainedDecoder(mBIHraw, sizeof(mBIHraw))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -515,9 +507,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
|
||||
toFeed = aCount;
|
||||
}
|
||||
|
||||
mContainedDecoder->Write(aBuffer, toFeed);
|
||||
mDataError = mContainedDecoder->HasDataError();
|
||||
if (mContainedDecoder->HasDataError()) {
|
||||
if (!WriteToContainedDecoder(aBuffer, toFeed)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -592,6 +582,19 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
nsICODecoder::WriteToContainedDecoder(const char* aBuffer, PRUint32 aCount)
|
||||
{
|
||||
mContainedDecoder->Write(aBuffer, aCount);
|
||||
if (mContainedDecoder->HasDataError()) {
|
||||
mDataError = mContainedDecoder->HasDataError();
|
||||
}
|
||||
if (mContainedDecoder->HasDecoderError()) {
|
||||
PostDecoderError(mContainedDecoder->GetDecoderError());
|
||||
}
|
||||
return !HasError();
|
||||
}
|
||||
|
||||
void
|
||||
nsICODecoder::ProcessDirEntry(IconDirEntry& aTarget)
|
||||
{
|
||||
|
@ -77,6 +77,10 @@ public:
|
||||
virtual void FinishInternal();
|
||||
|
||||
private:
|
||||
// Writes to the contained decoder and sets the appropriate errors
|
||||
// Returns true if there are no errors.
|
||||
bool WriteToContainedDecoder(const char* aBuffer, PRUint32 aCount);
|
||||
|
||||
// Processes a single dir entry of the icon resource
|
||||
void ProcessDirEntry(IconDirEntry& aTarget);
|
||||
// Sets the hotspot property of if we have a cursor
|
||||
|
Loading…
Reference in New Issue
Block a user