From fcddcfdec5496bb447875aa18b9d3ce8d23d5e41 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 5 Mar 2022 15:18:13 -0800 Subject: [PATCH] DevIL plugin: only save output if image processing succeeded MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit As suggested during the review of !2488.¹ ¹ https://gitlab.com/graphviz/graphviz/-/merge_requests/2488 --- plugin/devil/gvdevice_devil.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/plugin/devil/gvdevice_devil.c b/plugin/devil/gvdevice_devil.c index 7f8922f2f..74d29e8eb 100644 --- a/plugin/devil/gvdevice_devil.c +++ b/plugin/devil/gvdevice_devil.c @@ -34,7 +34,6 @@ Y_inv ( unsigned int width, unsigned int height, char *data) static void devil_format(GVJ_t * job) { ILuint ImgId; - ILenum Error; // Check if the shared lib's version matches the executable's version. if (ilGetInteger(IL_VERSION_NUM) < IL_VERSION || @@ -61,9 +60,15 @@ static void devil_format(GVJ_t * job) IL_BGRA, // Format IL_UNSIGNED_BYTE,// Type job->imagedata); - - // output to the provided open file handle - ilSaveF((ILenum)job->device.id, job->output_file); + + // check the last step succeeded + ILenum Error = ilGetError(); + if (Error == 0) { + // output to the provided open file handle + ilSaveF((ILenum)job->device.id, job->output_file); + } else { + fprintf(stderr, "Error: %s\n", iluErrorString(Error)); + } // We're done with the image, so delete it. ilDeleteImages(1, &ImgId); -- 2.40.0