summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2008-04-08 00:40:58 -0700
committerCarl Worth <cworth@cworth.org>2008-04-08 00:41:09 -0700
commitc1f7655f2fd5373a74d3fbf5977ebbd84e401e25 (patch)
tree0ad62e34eff8ad6cbeb589469c0cc99462b1853a
parent33c54ed240b319acb28ef370eef5188ad42a5737 (diff)
downloadcairo-c1f7655f2fd5373a74d3fbf5977ebbd84e401e25.tar.gz
Check surface->status and finished in cairo_surface_write_to_png
Without these checks, a user could hit an assertion failure by passing a finished surface to cairo_surface_write_to_png. Now we return a nice CAIRO_STATUS_SURFACE_FINISHED error in that case instead.
-rw-r--r--src/cairo-png.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cairo-png.c b/src/cairo-png.c
index f87ba2ce2..ad0457027 100644
--- a/src/cairo-png.c
+++ b/src/cairo-png.c
@@ -285,6 +285,12 @@ cairo_surface_write_to_png (cairo_surface_t *surface,
FILE *fp;
cairo_status_t status;
+ if (surface->status)
+ return surface->status;
+
+ if (surface->finished)
+ return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
+
fp = fopen (filename, "wb");
if (fp == NULL) {
switch (errno) {