From c96a19e3d97bfac20788e86013cf0efd881d18a6 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Thu, 11 Feb 2016 15:47:15 +0000 Subject: [PATCH] Test using Macro instead of &. Check for failure to open an image. Thanks Malvineous Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3965 --- src/dos/dos_programs.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp index 82fc324c..4086b167 100644 --- a/src/dos/dos_programs.cpp +++ b/src/dos/dos_programs.cpp @@ -298,7 +298,7 @@ public: return; } /* Not a switch so a normal directory/file */ - if (!(test.st_mode & S_IFDIR)) { + if (!S_ISDIR(test.st_mode)) { #ifdef OS2 HFILE cdrom_fd = 0; ULONG ulAction = 0; @@ -1216,7 +1216,7 @@ public: } } } - if ((test.st_mode & S_IFDIR)) { + if (S_ISDIR(test.st_mode)) { WriteOut(MSG_Get("PROGRAM_IMGMOUNT_MOUNT")); return; } @@ -1232,7 +1232,7 @@ public: if(fstype=="fat") { if (imgsizedetect) { FILE * diskfile = fopen(temp_line.c_str(), "rb+"); - if(!diskfile) { + if (!diskfile) { WriteOut(MSG_Get("PROGRAM_IMGMOUNT_INVALID_IMAGE")); return; } @@ -1377,6 +1377,10 @@ public: } else { FILE *newDisk = fopen(temp_line.c_str(), "rb+"); + if (!newDisk) { + WriteOut(MSG_Get("PROGRAM_IMGMOUNT_INVALID_IMAGE")); + return; + } fseek(newDisk,0L, SEEK_END); imagesize = (ftell(newDisk) / 1024);