]> de.git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - exec.c
prog_leavefunction needs to take the ++st into account - otherwise INSTR_RETURN ends...
[xonotic/gmqcc.git] / exec.c
diff --git a/exec.c b/exec.c
index 94e32a4a61ea760afb006fd327fa37fefa69da0f..66095f59a0edb1d35bc2f5b979491d04e19a3f26 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -36,9 +36,12 @@ static void loaderror(const char *fmt, ...)
     printf(": %s\n", strerror(err));
 }
 
-static void printvmerr(const char *fmt, ...)
+static void qcvmerror(qc_program *prog, const char *fmt, ...)
 {
     va_list ap;
+
+    prog->vmerror++;
+
     va_start(ap, fmt);
     vprintf(fmt, ap);
     va_end(ap);
@@ -52,7 +55,7 @@ qc_program* prog_load(const char *filename)
     size_t      i;
     FILE *file;
 
-    file = fopen(filename, "rb");
+    file = util_fopen(filename, "rb");
     if (!file)
         return NULL;
 
@@ -509,7 +512,7 @@ static qcint prog_leavefunction(qc_program *prog)
         exit(1);
     }
 
-    return st.stmt;
+    return st.stmt - 1; /* offset the ++st */
 }
 
 bool prog_exec(qc_program *prog, prog_section_function *func, size_t flags, long maxjumps)