From 9db3c6ad47922c4dc5458448c2fe79734bb4468d Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sat, 22 Jan 2022 23:01:41 -0500 Subject: Only open the ICO file once we have something to output --- tools/exe2ico.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/exe2ico.c b/tools/exe2ico.c index d84d3df..5cf0483 100644 --- a/tools/exe2ico.c +++ b/tools/exe2ico.c @@ -49,8 +49,6 @@ int main(int argc, char *argv[]) { SDL_RWops *exe = SDL_RWFromFile(exePath, "rb"); if (!exe) err(1, "%s", exePath); - SDL_RWops *ico = SDL_RWFromFile(icoPath, "wb"); - if (!ico) err(1, "%s", icoPath); // Read the EXE header if (SDL_ReadU8(exe) != 'M' || SDL_ReadU8(exe) != 'Z') { @@ -85,6 +83,9 @@ int main(int argc, char *argv[]) { SDL_RWseek(exe, 0x0C * count, RW_SEEK_CUR); } + SDL_RWops *ico = SDL_RWFromFile(icoPath, "wb"); + if (!ico) err(1, "%s", icoPath); + // Copy the ICONHEADER // https://devblogs.microsoft.com/oldnewthing/20101018-00/?p=12513 SDL_RWseek(exe, (Uint32)SDL_ReadLE16(exe) << alignmentShift, RW_SEEK_SET); -- cgit 1.4.1