summaryrefslogtreecommitdiff
path: root/boilerplate
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-01-02 17:45:26 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2009-01-03 21:52:58 +0000
commit75538962c8af11b1ec669caca6259b7769b5cc1d (patch)
tree2278de50cc182e0cc5aa475fe9c0a364e81cc45c /boilerplate
parent333158ec85cf3c610cc8965fc3f99d72b534cc2e (diff)
[boilerplate] Check the return of pclose()
pclose() returns the child exit status, so we can use that to detect errors in the convertor process.
Diffstat (limited to 'boilerplate')
-rw-r--r--boilerplate/cairo-boilerplate.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 1f06b19a..91032cde 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -1031,6 +1031,7 @@ cairo_boilerplate_convert_to_image (const char *filename, int page)
FILE *file;
unsigned int flags = 0;
cairo_surface_t *image;
+ int ret;
RETRY:
file = cairo_boilerplate_open_any2ppm (filename, page, flags);
@@ -1038,17 +1039,23 @@ cairo_boilerplate_convert_to_image (const char *filename, int page)
return cairo_boilerplate_surface_create_in_error (CAIRO_STATUS_READ_ERROR);
image = cairo_boilerplate_image_surface_create_from_ppm_stream (file);
- pclose (file);
+ ret = pclose (file);
if (cairo_surface_status (image) == CAIRO_STATUS_READ_ERROR) {
if (flags == 0) {
- /* Try again in process, e.g. to propagate a CRASH. */
+ /* Try again in a standalone process. */
cairo_surface_destroy (image);
flags = CAIRO_BOILERPLATE_OPEN_NO_DAEMON;
goto RETRY;
}
}
+ if (cairo_surface_status (image) == CAIRO_STATUS_SUCCESS && ret != 0) {
+ cairo_surface_destroy (image);
+ image =
+ cairo_boilerplate_surface_create_in_error (CAIRO_STATUS_READ_ERROR);
+ };
+
return image;
}