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.
This commit is contained in:
Carl Worth 2008-04-08 00:40:58 -07:00
parent 33c54ed240
commit c1f7655f2f

View file

@ -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) {