]> granicus.if.org Git - graphviz/commitdiff
DevIL plugin: only save output if image processing succeeded
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 5 Mar 2022 23:18:13 +0000 (15:18 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 6 Mar 2022 20:24:00 +0000 (12:24 -0800)
As suggested during the review of !2488.¹

¹ https://gitlab.com/graphviz/graphviz/-/merge_requests/2488

plugin/devil/gvdevice_devil.c

index 7f8922f2f8f17b64bbaf25a3ab4b4a99ee7dd1bb..74d29e8eb4fa875f6bba05b4b14e19425ccc2cb8 100644 (file)
@@ -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);