raysan5 / raylib

A simple and easy-to-use library to enjoy videogames programming

Home Page:http://www.raylib.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[rmodels] Read uninitialized values in `GenMeshTangents()`

ListeriaM opened this issue · comments

This commit (c4a51a3) will skip the last iteration if mesh->vertexCount % 3 == 0 (I suppose this is the normal case), which results in the last values for tan1 and tan2 being uninitialized. In any case this reads uninitialized memory from the end of tan1 and tan2 in the next loop regardless of the value of mesh->vertexCount. Did you mean to use i <= mesh->vertexCount - 3? Maybe a better option would be to assert that mesh->vertexCount % 3 == 0 and keep the old loop, since otherwise the last 1 or 2 values from tan1 and tan2 will always be uninitialized, which is probably not what you want.

\cc @sgalindo

commented

@ListeriaM Thanks for the further review, I didn't notice it...