From 643cba776b781d5724b42bd7d46fa7648513f58f Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 22 Aug 2020 10:57:13 +0300 Subject: [PATCH] - added initialization for line and sector portals Resizing of portal arrays during serialization could lead to processing of junk data https://forum.zdoom.org/viewtopic.php?t=67494 # Conflicts: # src/maploader/specials.cpp # src/portal.cpp # Conflicts: # src/portal.h --- src/portal.cpp | 4 ---- src/portal.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/portal.cpp b/src/portal.cpp index c8eb951be..3fc1f0e35 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -274,7 +274,6 @@ void P_SpawnLinePortal(line_t* line) line->portalindex = linePortals.Reserve(1); FLinePortal *port = &linePortals.Last(); - memset(port, 0, sizeof(FLinePortal)); port->mOrigin = line; port->mDestination = dst; port->mType = uint8_t(line->args[2]); // range check is done above. @@ -669,7 +668,6 @@ unsigned P_GetSkyboxPortal(AActor *actor) if (level.sectorPortals[i].mSkybox == actor) return i; } unsigned i = level.sectorPortals.Reserve(1); - memset(&level.sectorPortals[i], 0, sizeof(level.sectorPortals[i])); level.sectorPortals[i].mType = PORTS_SKYVIEWPOINT; level.sectorPortals[i].mFlags = actor->GetClass()->IsDescendantOf("SkyCamCompat") ? 0 : PORTSF_SKYFLATONLY; level.sectorPortals[i].mSkybox = actor; @@ -694,7 +692,6 @@ DEFINE_ACTION_FUNCTION(FSectorPortal, GetSkyboxPortal) unsigned P_GetPortal(int type, int plane, sector_t *from, sector_t *to, const DVector2 &displacement) { unsigned i = level.sectorPortals.Reserve(1); - memset(&level.sectorPortals[i], 0, sizeof(level.sectorPortals[i])); level.sectorPortals[i].mType = type; level.sectorPortals[i].mPlane = plane; level.sectorPortals[i].mOrigin = from; @@ -715,7 +712,6 @@ unsigned P_GetPortal(int type, int plane, sector_t *from, sector_t *to, const DV unsigned P_GetStackPortal(AActor *point, int plane) { unsigned i = level.sectorPortals.Reserve(1); - memset(&level.sectorPortals[i], 0, sizeof(level.sectorPortals[i])); level.sectorPortals[i].mType = PORTS_STACKEDSECTORTHING; level.sectorPortals[i].mPlane = plane; level.sectorPortals[i].mOrigin = point->target->Sector; diff --git a/src/portal.h b/src/portal.h index d8eda7a1e..fd9fcfa9f 100644 --- a/src/portal.h +++ b/src/portal.h @@ -191,6 +191,11 @@ struct FLinePortal double mSinRot; double mCosRot; portnode_t *lineportal_thinglist; + + FLinePortal() + { + memset(this, 0, sizeof *this); + } }; extern TArray linePortals; @@ -229,6 +234,11 @@ struct FSectorPortal double mPlaneZ; TObjPtr mSkybox; + FSectorPortal() + { + memset(this, 0, sizeof * this); + } + bool MergeAllowed() const { // For thing based stack sectors and regular skies the portal has no relevance for merging visplanes.