Fixed data alignment for PNG cursors (thanks @Kontrabant!)

This commit is contained in:
Sam Lantinga
2025-10-21 10:43:04 -07:00
parent af6f517453
commit 9d32e0e881

View File

@@ -196,7 +196,18 @@ static bool FillIconEntry(CURSORICONFILEDIRENTRY *entry, SDL_Surface *surface, i
static bool WriteIconSurface(SDL_IOStream *dst, SDL_Surface *surface)
{
return SDL_SavePNG_IO(surface, dst, false);
if (!SDL_SavePNG_IO(surface, dst, false)) {
return false;
}
// Image data offsets must be WORD aligned
Sint64 offset = SDL_TellIO(dst);
if (offset & 1) {
if (!SDL_WriteU8(dst, 0)) {
return false;
}
}
return true;
}
#else