diff options
author | Chris Robinson <[email protected]> | 2014-05-22 12:16:22 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-05-22 12:16:22 -0700 |
commit | a48f5d26fda855963fb930a75691b932e837dd2d (patch) | |
tree | 991a16603463b7222959c12f7e51aef6444765f7 /Alc/helpers.c | |
parent | 9008bcbe54313ad327a26d5a939b03f5e516a9de (diff) |
Ensure a proper amount of new elements are being reserved when inserting
Diffstat (limited to 'Alc/helpers.c')
-rw-r--r-- | Alc/helpers.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c index 4b5eceb7..a0230b7c 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -631,8 +631,12 @@ ALboolean vector_insert(void *ptr, size_t base_size, size_t obj_size, void *ins_ { ptrdiff_t ins_elem = ((char*)ins_pos - ((char*)(*vecptr) + base_size)) / obj_size; ptrdiff_t numins = ((const char*)datend - (const char*)datstart) / obj_size; - if(!vector_reserve(vecptr, base_size, VECTOR_SIZE(*vecptr)+numins, obj_size, AL_TRUE)) + + assert(numins > 0); + if(INT_MAX-VECTOR_SIZE(*vecptr) <= numins || + !vector_reserve(vecptr, base_size, VECTOR_SIZE(*vecptr)+numins, obj_size, AL_TRUE)) return AL_FALSE; + /* NOTE: ins_pos may have been invalidated if *vecptr moved. Use ins_elem instead. */ if(ins_elem < (*vecptr)->Size) { |