From ffd32542cc158826e90e4f71d92fb65c308f6506 Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Tue, 1 Oct 2013 20:00:54 -0400 Subject: [PATCH] [VarRegions] Prevent crashing on regions at the edge of reality itself (such as Null, Null) Demotes "Asking for patch out of bounds" to llwarns to prevent crashies, guards against some seemingly potent cases. --- indra/newview/llsurface.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp index 661358bfb..fd7c0da59 100644 --- a/indra/newview/llsurface.cpp +++ b/indra/newview/llsurface.cpp @@ -440,6 +440,11 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction) // Aurora Sim //neighbor_patchp = neighborp->getPatch(mPatchesPerEdge - 1, 0); neighbor_patchp = neighborp->getPatch(neighbor_offset[0] - 1, off); //neighborPatchesPerEdge - 1 + if (!neighbor_patchp) + { + mNeighbors[direction] = NULL; + return; + } // Aurora Sim patchp->connectNeighbor(neighbor_patchp, direction); @@ -451,6 +456,11 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction) // Aurora Sim //neighbor_patchp = neighborp->getPatch(mPatchesPerEdge - 1, mPatchesPerEdge - 1); neighbor_patchp = neighborp->getPatch(neighbor_offset[0] - 1, neighbor_offset[1] - 1); + if (!neighbor_patchp) + { + mNeighbors[direction] = NULL; + return; + } // Aurora Sim patchp->connectNeighbor(neighbor_patchp, direction); @@ -472,6 +482,11 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction) // Aurora Sim //neighbor_patchp = neighborp->getPatch(0, mPatchesPerEdge - 1); neighbor_patchp = neighborp->getPatch(off, neighbor_offset[1] - 1); //0 + if (!neighbor_patchp) + { + mNeighbors[direction] = NULL; + return; + } // Aurora Sim patchp->connectNeighbor(neighbor_patchp, direction); @@ -600,6 +615,7 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction) //neighbor_patchp = neighborp->getPatch(mPatchesPerEdge - 1, i); patchp = getPatch(0, i + own_offset[1]); neighbor_patchp = neighborp->getPatch(neighborPatchesPerEdge - 1, i + neighbor_offset[1]); + if (!neighbor_patchp) continue; // Aurora Sim patchp->connectNeighbor(neighbor_patchp, direction); @@ -620,6 +636,7 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction) //neighbor_patchp = neighborp->getPatch(mPatchesPerEdge - 1, i - 1); patchp = getPatch(0, i + own_offset[1]); neighbor_patchp = neighborp->getPatch(neighborPatchesPerEdge - 1, i - 1 + neighbor_offset[1]); + if (!neighbor_patchp) continue; // Aurora Sim patchp->connectNeighbor(neighbor_patchp, SOUTHWEST); @@ -637,6 +654,7 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction) //neighbor_patchp = neighborp->getPatch(mPatchesPerEdge - 1, i + 1); patchp = getPatch(0, i + own_offset[1]); neighbor_patchp = neighborp->getPatch(neighborPatchesPerEdge - 1, i + 1 + neighbor_offset[1]); + if (!neighbor_patchp) continue; // Aurora Sim patchp->connectNeighbor(neighbor_patchp, NORTHWEST); @@ -656,6 +674,7 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction) //neighbor_patchp = neighborp->getPatch(i, mPatchesPerEdge - 1); patchp = getPatch(i + own_offset[0], 0); neighbor_patchp = neighborp->getPatch(i + neighbor_offset[0], neighborPatchesPerEdge - 1); + if (!neighbor_patchp) continue; // Aurora Sim patchp->connectNeighbor(neighbor_patchp, direction); @@ -1321,12 +1340,12 @@ LLSurfacePatch *LLSurface::getPatch(const S32 x, const S32 y) const { if ((x < 0) || (x >= mPatchesPerEdge)) { - llerrs << "Asking for patch out of bounds" << llendl; + llwarns << "Asking for patch out of bounds" << llendl; return NULL; } if ((y < 0) || (y >= mPatchesPerEdge)) { - llerrs << "Asking for patch out of bounds" << llendl; + llwarns << "Asking for patch out of bounds" << llendl; return NULL; }