- 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
This commit is contained in:
alexey.lysiuk 2020-08-22 10:57:13 +03:00
parent 05f9df7057
commit f9708e225c
3 changed files with 10 additions and 4 deletions

View file

@ -127,7 +127,6 @@ void MapLoader::SpawnLinePortal(line_t* line)
line->portalindex = Level->linePortals.Reserve(1); line->portalindex = Level->linePortals.Reserve(1);
FLinePortal *port = &Level->linePortals.Last(); FLinePortal *port = &Level->linePortals.Last();
memset(port, 0, sizeof(FLinePortal));
port->mOrigin = line; port->mOrigin = line;
port->mDestination = dst; port->mDestination = dst;
port->mType = uint8_t(line->args[2]); // range check is done above. port->mType = uint8_t(line->args[2]); // range check is done above.

View file

@ -540,7 +540,6 @@ unsigned FLevelLocals::GetSkyboxPortal(AActor *actor)
if (sectorPortals[i].mSkybox == actor) return i; if (sectorPortals[i].mSkybox == actor) return i;
} }
unsigned i = sectorPortals.Reserve(1); unsigned i = sectorPortals.Reserve(1);
memset(&sectorPortals[i], 0, sizeof(sectorPortals[i]));
sectorPortals[i].mType = PORTS_SKYVIEWPOINT; sectorPortals[i].mType = PORTS_SKYVIEWPOINT;
sectorPortals[i].mFlags = actor->GetClass()->IsDescendantOf("SkyCamCompat") ? 0 : PORTSF_SKYFLATONLY; sectorPortals[i].mFlags = actor->GetClass()->IsDescendantOf("SkyCamCompat") ? 0 : PORTSF_SKYFLATONLY;
sectorPortals[i].mSkybox = actor; sectorPortals[i].mSkybox = actor;
@ -565,7 +564,6 @@ DEFINE_ACTION_FUNCTION(FLevelLocals, GetSkyboxPortal)
unsigned FLevelLocals::GetPortal(int type, int plane, sector_t *from, sector_t *to, const DVector2 &displacement) unsigned FLevelLocals::GetPortal(int type, int plane, sector_t *from, sector_t *to, const DVector2 &displacement)
{ {
unsigned i = sectorPortals.Reserve(1); unsigned i = sectorPortals.Reserve(1);
memset(&sectorPortals[i], 0, sizeof(sectorPortals[i]));
sectorPortals[i].mType = type; sectorPortals[i].mType = type;
sectorPortals[i].mPlane = plane; sectorPortals[i].mPlane = plane;
sectorPortals[i].mOrigin = from; sectorPortals[i].mOrigin = from;
@ -586,7 +584,6 @@ unsigned FLevelLocals::GetPortal(int type, int plane, sector_t *from, sector_t *
unsigned FLevelLocals::GetStackPortal(AActor *point, int plane) unsigned FLevelLocals::GetStackPortal(AActor *point, int plane)
{ {
unsigned i = sectorPortals.Reserve(1); unsigned i = sectorPortals.Reserve(1);
memset(&sectorPortals[i], 0, sizeof(sectorPortals[i]));
sectorPortals[i].mType = PORTS_STACKEDSECTORTHING; sectorPortals[i].mType = PORTS_STACKEDSECTORTHING;
sectorPortals[i].mPlane = plane; sectorPortals[i].mPlane = plane;
sectorPortals[i].mOrigin = point->target->Sector; sectorPortals[i].mOrigin = point->target->Sector;

View file

@ -193,6 +193,11 @@ struct FLinePortal
double mCosRot; double mCosRot;
portnode_t *lineportal_thinglist; portnode_t *lineportal_thinglist;
FLinePortalSpan *mGroup; FLinePortalSpan *mGroup;
FLinePortal()
{
memset(this, 0, sizeof *this);
}
}; };
struct FLinePortalSpan struct FLinePortalSpan
@ -238,6 +243,11 @@ struct FSectorPortal
double mPlaneZ; double mPlaneZ;
TObjPtr<AActor*> mSkybox; TObjPtr<AActor*> mSkybox;
FSectorPortal()
{
memset(this, 0, sizeof * this);
}
bool MergeAllowed() const bool MergeAllowed() const
{ {
// For thing based stack sectors and regular skies the portal has no relevance for merging visplanes. // For thing based stack sectors and regular skies the portal has no relevance for merging visplanes.