Fix potential integer overflows identified by Coverity
Convert ODK_LAST_STRESSABLE_TYPE to an aliased enum value so that ODK_FieldLength always returns a valid value instead of SIZE_MAX. PiperOrigin-RevId: 602823670 Change-Id: I7a843cacca8201677c0f31249112c04f6c3e04cb
This commit is contained in:
@@ -258,7 +258,7 @@ TEST(OdkTest, SerializeFieldsStress) {
|
||||
size_t total_size = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
fields[i].type = static_cast<ODK_FieldType>(
|
||||
std::rand() % static_cast<int>(ODK_LAST_STRESSABLE_TYPE));
|
||||
std::rand() % (static_cast<int>(ODK_LAST_STRESSABLE_TYPE) + 1));
|
||||
fields[i].value = malloc(ODK_AllocSize(fields[i].type));
|
||||
fields[i].name = "stress";
|
||||
total_size += ODK_FieldLength(fields[i].type);
|
||||
|
||||
Reference in New Issue
Block a user