Mesa (master): mesa/main/debug: Check if we successfully reopened the ppm file.

Rafael Antognolli rantogno at kemper.freedesktop.org
Fri Jun 9 17:22:08 UTC 2017


Module: Mesa
Branch: master
Commit: d42fc65bb3c8af6ed25baae17e6f2daec73338fc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d42fc65bb3c8af6ed25baae17e6f2daec73338fc

Author: Rafael Antognolli <rafael.antognolli at intel.com>
Date:   Mon Jun  5 11:04:26 2017 -0700

mesa/main/debug: Check if we successfully reopened the ppm file.

Since we created the file, we should be able to reopen it for appending, but
some weird filesystem error could cause that to be false. So simply check
whether we could reopen it or not.

CID: 1177144
Signed-off-by: Rafael Antognolli <rafael.antognolli at intel.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

 src/mesa/main/debug.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c
index 7b76a94969..d7e0143a8f 100644
--- a/src/mesa/main/debug.c
+++ b/src/mesa/main/debug.c
@@ -235,6 +235,11 @@ write_ppm(const char *filename, const GLubyte *buffer, int width, int height,
       fprintf(f,"255\n");
       fclose(f);
       f = fopen( filename, "ab" );  /* reopen in binary append mode */
+      if (!f) {
+         fprintf(stderr, "Error while reopening %s in write_ppm()\n",
+                 filename);
+         return;
+      }
       for (y=0; y < height; y++) {
          for (x = 0; x < width; x++) {
             int yy = invert ? (height - 1 - y) : y;




More information about the mesa-commit mailing list