summary refs log tree commit diff
path: root/tools/exe2ico.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/exe2ico.c')
-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);