1
Fork 0

This fixes a bug the key_struct_vector_read function.

This has been reported by Rama Krishna Chitta.
main
Fabiano C. Botelho 2013-04-20 01:44:25 -07:00
parent 9f999ef428
commit 2cf5c15cf6
1 changed files with 5 additions and 1 deletions

View File

@ -96,11 +96,15 @@ static int key_struct_vector_read(void *data, char **key, cmph_uint32 *keylen)
{
cmph_struct_vector_t *cmph_struct_vector = (cmph_struct_vector_t *)data;
char *keys_vd = (char *)cmph_struct_vector->vector;
cmph_uint64 keys_vd_offset;
size_t size;
*keylen = cmph_struct_vector->key_len;
size = *keylen;
*key = (char *)malloc(size);
memcpy(*key, (keys_vd + (cmph_struct_vector->position * cmph_struct_vector->struct_size) + cmph_struct_vector->key_offset), size);
keys_vd_offset = ((cmph_uint64)cmph_struct_vector->position *
(cmph_uint64)cmph_struct_vector->struct_size) +
(cmph_uint64)cmph_struct_vector->key_offset;
memcpy(*key, keys_vd + keys_vd_offset, size);
cmph_struct_vector->position = cmph_struct_vector->position + 1;
return (int)(*keylen);
}