Commits

Tofu Linden  committed 40e6307

EXT-4388 Crash in octree line segment intersection code (getMask)
Add yet more paranoia-and-return-or-assert, this time for +-INF in input vector.
To be reviewed by Bao.
(transplanted from 2012f21d23c66179345fb26148cfbe19835b325e)

  • Participants
  • Parent commits 3530ae2

Comments (0)

Files changed (2)

File indra/llmath/v2math.h

 		void	setVec(const LLVector2 &vec);	// deprecated
 		void	setVec(const F32 *vec);			// deprecated
 
+		inline bool isFinite() const; // checks to see if all values of LLVector2 are finite
+
 		F32		length() const;				// Returns magnitude of LLVector2
 		F32		lengthSquared() const;		// Returns magnitude squared of LLVector2
 		F32		normalize();					// Normalizes and returns the magnitude of LLVector2
 	mV[VY] = vec[VY];
 }
 
+
 // LLVector2 Magnitude and Normalization Functions
 
 inline F32 LLVector2::length(void) const
 	return (mag);
 }
 
+// checker
+inline bool LLVector2::isFinite() const
+{
+	return (llfinite(mV[VX]) && llfinite(mV[VY]));
+}
+
 // deprecated
 inline F32		LLVector2::magVec(void) const
 {

File indra/llrender/llimagegl.cpp

 
 	if (mPickMask)
 	{
-		F32 u = tc.mV[0] - floorf(tc.mV[0]);
-		F32 v = tc.mV[1] - floorf(tc.mV[1]);
+		F32 u,v;
+		if (LL_LIKELY(tc.isFinite()))
+		{
+			u = tc.mV[0] - floorf(tc.mV[0]);
+			v = tc.mV[1] - floorf(tc.mV[1]);
+		}
+		else
+		{
+			LL_WARNS_ONCE("render") << "Ugh, non-finite u/v in mask pick" << LL_ENDL;
+			u = v = 0.f;
+			llassert(false);
+		}
 
 		if (LL_UNLIKELY(u < 0.f || u > 1.f ||
 				v < 0.f || v > 1.f))