[cairo-commit] 2 commits - src/cairo-png.c test/cairo-test.c
Chris Wilson
ickle at kemper.freedesktop.org
Tue Aug 19 15:51:45 PDT 2008
src/cairo-png.c | 9 ++++++++-
test/cairo-test.c | 1 +
2 files changed, 9 insertions(+), 1 deletion(-)
New commits:
commit 186e7a2602cf140ac03b730b95ed10f25f9319c6
Author: Alex Rostovtsev <tetromino at gmail.com>
Date: Tue Aug 19 23:45:40 2008 +0100
[png] Specify a no-op flush callback (NULL deref)
libpng changed behaviour in v1.2.30 to call the png_ptr->output_flush_fn
in png_write_end(). If no flush function is provided with
png_set_write_fn(), libpng will use its default fflush() instead - which
assumes that closure passed is a FILE* and not an arbitrary user pointer.
Consequently, we must actually set a dummy output_flush_fn to avoid
segfaulting.
diff --git a/src/cairo-png.c b/src/cairo-png.c
index ae3a1f7..1b7df9a 100644
--- a/src/cairo-png.c
+++ b/src/cairo-png.c
@@ -119,6 +119,13 @@ png_simple_warning_callback (png_structp png,
}
+/* Starting with libpng-1.2.30, we must explicitly specify an output_flush_fn.
+ * Otherwise, we will segfault if we are writing to a stream. */
+static void
+png_simple_output_flush_fn (png_structp png_ptr)
+{
+}
+
static cairo_status_t
write_png (cairo_surface_t *surface,
png_rw_ptr write_func,
@@ -179,7 +186,7 @@ write_png (cairo_surface_t *surface,
goto BAIL3;
#endif
- png_set_write_fn (png, closure, write_func, NULL);
+ png_set_write_fn (png, closure, write_func, png_simple_output_flush_fn);
switch (image->format) {
case CAIRO_FORMAT_ARGB32:
commit 5712a2c619b265a7ede5cd32049bce456131c64b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Aug 19 15:17:45 2008 +0100
[test] Destroy test ouput image on failure.
Add the missing cairo_surface_destroy(). Sigh, less haste more speed.
diff --git a/test/cairo-test.c b/test/cairo-test.c
index 80e62ed..99478ca 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -641,6 +641,7 @@ cairo_test_for_target (cairo_test_context_t *ctx,
if (diff_status) {
cairo_test_log (ctx, "Error: Failed to write output image: %s\n",
cairo_status_to_string (diff_status));
+ cairo_surface_destroy (test_image);
ret = CAIRO_TEST_FAILURE;
goto UNWIND_CAIRO;
}
More information about the cairo-commit
mailing list