Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-09-09 13:33:34 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-09-09 13:33:34 +0400
commit0392acc607d26f3fb2681c7d8b0e5ad3a2d50d9a (patch)
tree0051b765644349483d89f181620a79b35f9dfabc /intern/mikktspace
parent35e3111475f8366e3c3fa818a2371cf1c6888f91 (diff)
fix [#36685] crash calculating tangent space data on degenerate geometry
the error was that the range check was done on the float before converting to an int. now convert to and int first and ensure a valid range on that.
Diffstat (limited to 'intern/mikktspace')
-rw-r--r--intern/mikktspace/mikktspace.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/intern/mikktspace/mikktspace.c b/intern/mikktspace/mikktspace.c
index 018869f36b6..62aa2da2517 100644
--- a/intern/mikktspace/mikktspace.c
+++ b/intern/mikktspace/mikktspace.c
@@ -440,8 +440,8 @@ static const int g_iCells = 2048;
static NOINLINE int FindGridCell(const float fMin, const float fMax, const float fVal)
{
const float fIndex = g_iCells * ((fVal-fMin)/(fMax-fMin));
- const int iIndex = fIndex<0?0:((int)fIndex);
- return iIndex<g_iCells?iIndex:(g_iCells-1);
+ const int iIndex = (int)fIndex;
+ return iIndex < g_iCells ? (iIndex >= 0 ? iIndex : 0) : (g_iCells - 1);
}
static void MergeVertsFast(int piTriList_in_and_out[], STmpVert pTmpVert[], const SMikkTSpaceContext * pContext, const int iL_in, const int iR_in);