foxygit / doom Log in
commit e7262d2a8859501152ef22bc7cb9dcc26b05c402
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Sat Aug 29 20:12:49 2009 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Sat Aug 29 20:12:49 2009 +0000

    Fix crash when specifying an invalid filename.

    Subversion-branch: /branches/opl-branch
    Subversion-revision: 1634
---
 opl/examples/droplay.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/opl/examples/droplay.c b/opl/examples/droplay.c
index b1656815..4c2fc2f8 100644
--- a/opl/examples/droplay.c
+++ b/opl/examples/droplay.c
@@ -183,6 +183,12 @@ void PlayFile(char *filename)

     timer_data.fstream = fopen(filename, "rb");

+    if (timer_data.fstream == NULL)
+    {
+        fprintf(stderr, "Failed to open %s\n", filename);
+        exit(-1);
+    }
+
     if (fread(buf, 1, 8, timer_data.fstream) < 8)
     {
         fprintf(stderr, "failed to read raw OPL header\n");
@@ -226,7 +232,6 @@ int main(int argc, char *argv[])

     Init();
     ClearAllRegs();
-    SDL_Delay(1000);

     PlayFile(argv[1]);