mirror of
https://github.com/raysan5/raylib.git
synced 2026-07-12 12:19:44 +00:00
REVIEWED: Replace assert() by runtime checks - ROS: CLN-012
This commit is contained in:
23
src/external/tinyobj_loader_c.h
vendored
23
src/external/tinyobj_loader_c.h
vendored
@@ -1020,7 +1020,12 @@ static int parseLine(Command *command, const char *p, unsigned int p_len,
|
||||
int triangulate) {
|
||||
char linebuf[4096];
|
||||
const char *token;
|
||||
assert(p_len < 4095);
|
||||
|
||||
// @raysan5:
|
||||
// WARNING: If -DNDEBUG is set when compiling, assertions will not
|
||||
// be present in the compiled binary, replacing by a runtime check
|
||||
//assert(p_len < 4095);
|
||||
if (p_len > 4095) return 0;
|
||||
|
||||
memcpy(linebuf, p, p_len);
|
||||
linebuf[p_len] = '\0';
|
||||
@@ -1102,8 +1107,12 @@ static int parseLine(Command *command, const char *p, unsigned int p_len,
|
||||
tinyobj_vertex_index_t i1;
|
||||
tinyobj_vertex_index_t i2 = f[1];
|
||||
|
||||
assert(3 * num_f < TINYOBJ_MAX_FACES_PER_F_LINE);
|
||||
|
||||
// @raysan5:
|
||||
// WARNING: If -DNDEBUG is set when compiling, assertions will not
|
||||
// be present in the compiled binary, replacing by a runtime check
|
||||
//assert(3 * num_f < TINYOBJ_MAX_FACES_PER_F_LINE);
|
||||
if (3*num_f > TINYOBJ_MAX_FACES_PER_F_LINE) return 0;
|
||||
|
||||
for (k = 2; k < num_f; k++) {
|
||||
i1 = i2;
|
||||
i2 = f[k];
|
||||
@@ -1119,7 +1128,13 @@ static int parseLine(Command *command, const char *p, unsigned int p_len,
|
||||
|
||||
} else {
|
||||
unsigned int k = 0;
|
||||
assert(num_f < TINYOBJ_MAX_FACES_PER_F_LINE);
|
||||
|
||||
// @raysan5:
|
||||
// WARNING: If -DNDEBUG is set when compiling, assertions will not
|
||||
// be present in the compiled binary, replacing by a runtime check
|
||||
//assert(num_f < TINYOBJ_MAX_FACES_PER_F_LINE);
|
||||
if (num_f > TINYOBJ_MAX_FACES_PER_F_LINE) return 0;
|
||||
|
||||
for (k = 0; k < num_f; k++) {
|
||||
command->f[k] = f[k];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user