From 6acf7b733879850815059e470644637f208850c4 Mon Sep 17 00:00:00 2001
From: Syping <schiedelrafael@keppe.org>
Date: Wed, 7 Jun 2023 06:12:24 +0200
Subject: [PATCH] RagePhoto.c: fix potential memory issue

---
 src/RagePhoto.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/RagePhoto.c b/src/RagePhoto.c
index 139c9f2..9d98fbe 100644
--- a/src/RagePhoto.c
+++ b/src/RagePhoto.c
@@ -926,6 +926,10 @@ bool ragephoto_savefilef(ragephoto_t instance_t, const char *filename, uint32_t
 #else
     FILE *file = fopen(filename, "wb");
 #endif
+    if (!file) {
+        free(data);
+        return false;
+    }
     const size_t fileWsize = fwrite(data, sizeof(char), fileSize, file);
     fclose(file);
     free(data);