shithub: rgbds

Download patch

ref: 280ca83acdbe92d6c874271bfd8d93a76bddfea5
parent: 2e9c68f8c37e8188bee63e7d164ee59ca6bc5d52
author: Sanqui <[email protected]>
date: Mon Mar 28 16:46:10 EDT 2016

Fix opening nonexistent overlay files

--- a/src/link/output.c
+++ b/src/link/output.c
@@ -104,15 +104,19 @@
 	if ((f = fopen(tzOutname, "wb"))) {
 		if (tzOverlayname) {
 			f_overlay = fopen(tzOverlayname, "rb");
+			if (!f_overlay) {
+				fprintf(stderr, "Failed to open overlay file %s\n", tzOverlayname);
+				exit(1);
+			}
 			fseek(f_overlay, 0, SEEK_END);
 			if (ftell(f_overlay) % 0x4000 != 0) {
-			    fprintf(stderr, "Overlay file must be aligned to 0x4000 bytes");
-			    exit(1);
+				fprintf(stderr, "Overlay file must be aligned to 0x4000 bytes\n");
+				exit(1);
 			}
 			MaxOverlayBank = (ftell(f_overlay) / 0x4000) - 1;
 			if (MaxOverlayBank < 1) {
-			    fprintf(stderr, "Overlay file be at least 0x8000 bytes");
-			    exit(1);
+				fprintf(stderr, "Overlay file be at least 0x8000 bytes\n");
+				exit(1);
 			}
 			if (MaxOverlayBank > MaxBankUsed) {
 				MaxBankUsed = MaxOverlayBank;