Add bounds checking to GetMidTexturePosition, add assert to P_GetMidTexturePosition

This commit is contained in:
Ricardo Luís Vaz Silva 2024-10-05 23:03:05 -03:00
parent 2e795bebb4
commit 19e1d400e4

View file

@ -229,6 +229,8 @@ bool P_GetMidTexturePosition(const line_t *line, int sideno, double *ptextop, do
{
if (line->sidedef[0]==NULL || line->sidedef[1]==NULL) return false;
assert(sideno >= 0 && sideno <= 1);
side_t *side = line->sidedef[sideno];
FTextureID texnum = side->GetTexture(side_t::mid);
if (!texnum.isValid()) return false;
@ -266,6 +268,9 @@ DEFINE_ACTION_FUNCTION(_Line, GetMidTexturePosition)
double top = 0.0;
double bottom = 0.0;
if(side < 0) ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "side is negative");
else if(side > 1) ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "side is greater than one");
bool res = P_GetMidTexturePosition(self,side,&top,&bottom);
if (numret > 2) ret[2].SetFloat(bottom);
if (numret > 1) ret[1].SetFloat(top);