fix segfault myhtml_tag_get_by_id

If pass some big tag id value to myhtml_tag_get_by_id, then mcsimple_get_by_absolute_position access to uninitialized memory area. 
Now checks calculated list index by mcsimple->list_pos_length_used value to fix this.
This commit is contained in:
Кирилл Жумарин 2018-05-20 18:30:50 +03:00 committed by GitHub
parent e15a4e5dd4
commit d22b12b000
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -119,7 +119,12 @@ void * mcsimple_malloc(mcsimple_t *mcsimple)
void * mcsimple_get_by_absolute_position(mcsimple_t *mcsimple, size_t pos)
{
pos *= mcsimple->struct_size;
return &mcsimple->list[ (pos / mcsimple->list_size) ][ (pos % mcsimple->list_size) ];
size_t list_index = pos / mcsimple->list_size;
if(list_index >= mcsimple->list_pos_length_used)
return NULL;
return &mcsimple->list[list_index][ (pos % mcsimple->list_size) ];
}