]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
In prog reset functions, do not call functions unless prog->loaded.
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 6 Aug 2013 13:40:35 +0000 (13:40 +0000)
committerRudolf Polzer <divverent@xonotic.org>
Tue, 6 Aug 2013 13:47:21 +0000 (15:47 +0200)
This fixes segfaults in case progs loading itself may have caused Host_Error.

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11995 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=97703839c970c295ba6173da463906bdec6d55cd

csprogs.c
menu.c
svvm_cmds.c

index 36cecf839c7910678adc9b18fa1d176e00e7ea34..fa5e690b1ecf6ef064667325237e7a6ab0bd207e 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -1160,10 +1160,13 @@ void CL_VM_ShutDown (void)
        if(!cl.csqc_loaded)
                return;
        CSQC_BEGIN
-               PRVM_clientglobalfloat(time) = cl.time;
-               PRVM_clientglobaledict(self) = 0;
-               if (PRVM_clientfunction(CSQC_Shutdown))
-                       prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Shutdown), "QC function CSQC_Shutdown is missing");
+               if (prog->loaded)
+               {
+                       PRVM_clientglobalfloat(time) = cl.time;
+                       PRVM_clientglobaledict(self) = 0;
+                       if (PRVM_clientfunction(CSQC_Shutdown))
+                               prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Shutdown), "QC function CSQC_Shutdown is missing");
+               }
                PRVM_Prog_Reset(prog);
        CSQC_END
        Con_DPrint("CSQC ^1unloaded\n");
diff --git a/menu.c b/menu.c
index 34a8de7f964059932023ee112d15b8241570c785..d1311ca35d85823bd840614e3b2b6fd02e1ec136 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -5333,8 +5333,8 @@ static void MP_NewMap(void)
 static void MP_Shutdown (void)
 {
        prvm_prog_t *prog = MVM_prog;
-
-       prog->ExecuteProgram(prog, PRVM_menufunction(m_shutdown),"m_shutdown() required");
+       if (prog->loaded)
+               prog->ExecuteProgram(prog, PRVM_menufunction(m_shutdown),"m_shutdown() required");
 
        // reset key_dest
        key_dest = key_game;
index e9d51fdf75df165ac94bd4f451447b1c88067e61..c75dd07740ae4599409952601096c7937909179e 100644 (file)
@@ -3835,7 +3835,8 @@ void SVVM_init_cmd(prvm_prog_t *prog)
 void SVVM_reset_cmd(prvm_prog_t *prog)
 {
        World_End(&sv.world);
-       if(PRVM_serverfunction(SV_Shutdown))
+
+       if(prog->loaded && PRVM_serverfunction(SV_Shutdown))
        {
                func_t s = PRVM_serverfunction(SV_Shutdown);
                PRVM_serverglobalfloat(time) = sv.time;