REVIEWED: Replace assert() by runtime checks - ROS: CLN-012
This commit is contained in:
parent
c31666fe2a
commit
97d2b0146c
1 changed files with 19 additions and 4 deletions
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) {
|
int triangulate) {
|
||||||
char linebuf[4096];
|
char linebuf[4096];
|
||||||
const char *token;
|
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);
|
memcpy(linebuf, p, p_len);
|
||||||
linebuf[p_len] = '\0';
|
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 i1;
|
||||||
tinyobj_vertex_index_t i2 = f[1];
|
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++) {
|
for (k = 2; k < num_f; k++) {
|
||||||
i1 = i2;
|
i1 = i2;
|
||||||
i2 = f[k];
|
i2 = f[k];
|
||||||
|
|
@ -1119,7 +1128,13 @@ static int parseLine(Command *command, const char *p, unsigned int p_len,
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
unsigned int k = 0;
|
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++) {
|
for (k = 0; k < num_f; k++) {
|
||||||
command->f[k] = f[k];
|
command->f[k] = f[k];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue