From aa0111e068b8bf53b8f68768458b4abc8f24b0ef Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 21 Oct 2025 11:33:23 -0700
Subject: [PATCH] Fail image saving if closing the IOStream fails
---
src/IMG.c | 2 +-
src/IMG_anim_encoder.c | 2 +-
src/IMG_avif.c | 2 +-
src/IMG_jpg.c | 2 +-
src/IMG_libpng.c | 2 +-
src/IMG_tga.c | 2 +-
src/IMG_webp.c | 2 +-
7 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/IMG.c b/src/IMG.c
index 95117162..726123e9 100644
--- a/src/IMG.c
+++ b/src/IMG.c
@@ -435,7 +435,7 @@ bool IMG_SaveTyped_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio, con
done:
if (dst && closeio) {
- SDL_CloseIO(dst);
+ result &= SDL_CloseIO(dst);
}
return result;
}
diff --git a/src/IMG_anim_encoder.c b/src/IMG_anim_encoder.c
index 631393ac..83aeb69c 100644
--- a/src/IMG_anim_encoder.c
+++ b/src/IMG_anim_encoder.c
@@ -183,7 +183,7 @@ bool IMG_CloseAnimationEncoder(IMG_AnimationEncoder *encoder)
bool result = encoder->Close(encoder);
if (encoder->closeio) {
- SDL_CloseIO(encoder->dst);
+ result &= SDL_CloseIO(encoder->dst);
}
SDL_free(encoder);
return result;
diff --git a/src/IMG_avif.c b/src/IMG_avif.c
index e0c8de1d..5fbb5a86 100644
--- a/src/IMG_avif.c
+++ b/src/IMG_avif.c
@@ -752,7 +752,7 @@ bool IMG_SaveAVIF_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio, int
done:
if (closeio) {
- SDL_CloseIO(dst);
+ result &= SDL_CloseIO(dst);
}
return result;
}
diff --git a/src/IMG_jpg.c b/src/IMG_jpg.c
index 69fe543b..97fd939a 100644
--- a/src/IMG_jpg.c
+++ b/src/IMG_jpg.c
@@ -788,7 +788,7 @@ bool IMG_SaveJPG_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio, int q
done:
if (closeio) {
- SDL_CloseIO(dst);
+ result &= SDL_CloseIO(dst);
}
return result;
}
diff --git a/src/IMG_libpng.c b/src/IMG_libpng.c
index c97f6384..365e6ca4 100644
--- a/src/IMG_libpng.c
+++ b/src/IMG_libpng.c
@@ -706,7 +706,7 @@ bool IMG_SavePNG_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio)
}
if (closeio) {
- SDL_CloseIO(dst);
+ result &= SDL_CloseIO(dst);
}
return result;
diff --git a/src/IMG_tga.c b/src/IMG_tga.c
index a19636d9..ba86b9ef 100644
--- a/src/IMG_tga.c
+++ b/src/IMG_tga.c
@@ -519,7 +519,7 @@ bool IMG_SaveTGA_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio)
SDL_SeekIO(dst, start, SDL_IO_SEEK_SET);
}
if (closeio) {
- SDL_CloseIO(dst);
+ result &= SDL_CloseIO(dst);
}
return result;
}
diff --git a/src/IMG_webp.c b/src/IMG_webp.c
index 6563705a..b33ac7e8 100644
--- a/src/IMG_webp.c
+++ b/src/IMG_webp.c
@@ -818,7 +818,7 @@ bool IMG_SaveWEBP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio, floa
}
if (closeio) {
- SDL_CloseIO(dst);
+ result &= SDL_CloseIO(dst);
}
return result;