[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da
commit-queue at webkit.org
commit-queue at webkit.org
Wed Dec 22 17:57:27 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit ed64c5ee3e4b85c324fb7f0048c5765f9155f704
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Dec 3 08:53:41 2010 +0000
2010-12-03 Noel Gordon <noel.gordon at gmail.com>
Reviewed by Darin Fisher.
[chromium] PNG encoder leaks memory on png_write_row errors.
https://bugs.webkit.org/show_bug.cgi?id=50439
Move the creation of needed C++ objects before the setjmp() point so
those objects have their destructors called if libpng errors invoke
the setjmp() return path.
Other minor cleanup: use the skia bitmap locker class, and remove the
PNGDestroyer class - instead directly call png_destroy_write_struct()
at each of the encodeImpl() return points.
No change in behaviour, so no new tests.
* platform/image-encoders/skia/PNGImageEncoder.cpp:
(WebCore::encodeImpl):
(WebCore::PNGImageEncoder::encode):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73250 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 096a290..22d5160 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,24 @@
+2010-12-03 Noel Gordon <noel.gordon at gmail.com>
+
+ Reviewed by Darin Fisher.
+
+ [chromium] PNG encoder leaks memory on png_write_row errors.
+ https://bugs.webkit.org/show_bug.cgi?id=50439
+
+ Move the creation of needed C++ objects before the setjmp() point so
+ those objects have their destructors called if libpng errors invoke
+ the setjmp() return path.
+
+ Other minor cleanup: use the skia bitmap locker class, and remove the
+ PNGDestroyer class - instead directly call png_destroy_write_struct()
+ at each of the encodeImpl() return points.
+
+ No change in behaviour, so no new tests.
+
+ * platform/image-encoders/skia/PNGImageEncoder.cpp:
+ (WebCore::encodeImpl):
+ (WebCore::PNGImageEncoder::encode):
+
2010-12-02 Philippe Normand <pnormand at igalia.com>
Reviewed by Eric Carlson.
diff --git a/WebCore/platform/image-encoders/skia/PNGImageEncoder.cpp b/WebCore/platform/image-encoders/skia/PNGImageEncoder.cpp
index dc7d067..695c1e9 100644
--- a/WebCore/platform/image-encoders/skia/PNGImageEncoder.cpp
+++ b/WebCore/platform/image-encoders/skia/PNGImageEncoder.cpp
@@ -83,24 +83,6 @@ void encoderWriteCallback(png_structp png, png_bytep data, png_size_t size)
memcpy(&(*state->m_out)[oldSize], data, size);
}
-// Automatically destroys the given write structs on destruction to make
-// cleanup and error handling code cleaner.
-class PNGWriteStructDestroyer {
-public:
- PNGWriteStructDestroyer(png_struct** ps, png_info** pi)
- : m_pngStruct(ps)
- , m_pngInfo(pi) {
- }
-
- ~PNGWriteStructDestroyer() {
- png_destroy_write_struct(m_pngStruct, m_pngInfo);
- }
-
-private:
- png_struct** m_pngStruct;
- png_info** m_pngInfo;
-};
-
static bool encodeImpl(const unsigned char* input,
const IntSize& size,
int bytesPerRow,
@@ -127,17 +109,16 @@ static bool encodeImpl(const unsigned char* input,
png_destroy_write_struct(&pngPtr, NULL);
return false;
}
- PNGWriteStructDestroyer destroyer(&pngPtr, &infoPtr);
+
+ OwnArrayPtr<unsigned char> rowPixels(new unsigned char[imageSize.width() * outputColorComponents]);
+ PNGEncoderState state(output);
if (setjmp(png_jmpbuf(pngPtr))) {
- // The destroyer will ensure that the structures are cleaned up in this
- // case, even though we may get here as a jump from random parts of the
- // PNG library called below.
+ png_destroy_write_struct(&pngPtr, &infoPtr);
return false;
}
// Set our callback for libpng to give us the data.
- PNGEncoderState state(output);
png_set_write_fn(pngPtr, &state, encoderWriteCallback, NULL);
png_set_IHDR(pngPtr, infoPtr, imageSize.width(), imageSize.height(), 8, pngOutputColorType,
@@ -145,13 +126,13 @@ static bool encodeImpl(const unsigned char* input,
PNG_FILTER_TYPE_DEFAULT);
png_write_info(pngPtr, infoPtr);
- OwnArrayPtr<unsigned char> rowPixels(new unsigned char[imageSize.width() * outputColorComponents]);
for (int y = 0; y < imageSize.height(); ++y) {
preMultipliedBGRAtoRGBA(&input[y * bytesPerRow], imageSize.width(), rowPixels.get());
png_write_row(pngPtr, rowPixels.get());
}
png_write_end(pngPtr, infoPtr);
+ png_destroy_write_struct(&pngPtr, &infoPtr);
return true;
}
@@ -161,10 +142,8 @@ bool PNGImageEncoder::encode(const SkBitmap& image, Vector<unsigned char>* outpu
if (image.config() != SkBitmap::kARGB_8888_Config)
return false; // Only support ARGB 32 bpp skia bitmaps.
- image.lockPixels();
- bool result = encodeImpl(static_cast<unsigned char*>(image.getPixels()), IntSize(image.width(), image.height()), image.rowBytes(), output);
- image.unlockPixels();
- return result;
+ SkAutoLockPixels bitmapLock(image);
+ return encodeImpl(static_cast<unsigned char*>(image.getPixels()), IntSize(image.width(), image.height()), image.rowBytes(), output);
}
} // namespace WebCore
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list