From: Matthew Fernandez Date: Sat, 5 Mar 2022 23:18:13 +0000 (-0800) Subject: DevIL plugin: only save output if image processing succeeded X-Git-Tag: 4.0.0~190^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fcddcfdec5496bb447875aa18b9d3ce8d23d5e41;p=graphviz DevIL plugin: only save output if image processing succeeded As suggested during the review of !2488.¹ ¹ https://gitlab.com/graphviz/graphviz/-/merge_requests/2488 --- 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);