From 5be9773eca832b061645abe72201ae83ed03900d Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sun, 22 Nov 2015 17:53:22 -0500 Subject: [PATCH] fix another crash with invalid SOAP (soap was detached before SOAP update function ran) --- src/simulation/elements/SOAP.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/simulation/elements/SOAP.cpp b/src/simulation/elements/SOAP.cpp index 3c4f0bfe63..2a320f79ac 100644 --- a/src/simulation/elements/SOAP.cpp +++ b/src/simulation/elements/SOAP.cpp @@ -50,13 +50,13 @@ Element_SOAP::Element_SOAP() //#TPT-Directive ElementHeader Element_SOAP static void detach(Simulation * sim, int i) void Element_SOAP::detach(Simulation * sim, int i) { - if ((sim->parts[i].ctype&2) == 2 && sim->parts[sim->parts[i].tmp].type == PT_SOAP) + if ((sim->parts[i].ctype&2) == 2 && sim->parts[i].tmp >= 0 && sim->parts[i].tmp < NPART && sim->parts[sim->parts[i].tmp].type == PT_SOAP) { if ((sim->parts[sim->parts[i].tmp].ctype&4) == 4) sim->parts[sim->parts[i].tmp].ctype ^= 4; } - if ((sim->parts[i].ctype&4) == 4 && sim->parts[sim->parts[i].tmp2].type == PT_SOAP) + if ((sim->parts[i].ctype&4) == 4 && sim->parts[i].tmp2 >= 0 && sim->parts[i].tmp2 < NPART && sim->parts[sim->parts[i].tmp2].type == PT_SOAP) { if ((sim->parts[sim->parts[i].tmp2].ctype&2) == 2) sim->parts[sim->parts[i].tmp2].ctype ^= 2;