summary refs log tree commit diff
path: root/tools
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2022-01-22 23:01:41 -0500
committerJune McEnroe <june@causal.agency>2022-01-22 23:01:41 -0500
commit9db3c6ad47922c4dc5458448c2fe79734bb4468d (patch)
treee0497de58687faca244c086afe61e482f51cec89 /tools
parentFix size of padding counter (diff)
downloadwep-9db3c6ad47922c4dc5458448c2fe79734bb4468d.tar.gz
wep-9db3c6ad47922c4dc5458448c2fe79734bb4468d.zip
Only open the ICO file once we have something to output
Diffstat (limited to 'tools')
-rw-r--r--tools/exe2ico.c5
1 files changed, 3 insertions, 2 deletions
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);