fixed edge-case when padding was not there and zero-terminator got overridden
This commit is contained in:
parent
14052a8421
commit
21351fd2b4
3
simap.h
3
simap.h
@ -140,6 +140,8 @@ static inline unsigned int get_size_padding(unsigned int size, unsigned int alig
|
||||
static inline uint32_t simap_elem_storage_size(const char *key) {
|
||||
uint32_t keysize = strlen(key);
|
||||
uint32_t padding = get_size_padding(keysize, 8);
|
||||
/* XXX: The exactly 8byte keys need a zero terminator too (would be overridden without this) */
|
||||
padding += (keysize == 8) ? 8 : 0;
|
||||
|
||||
return keysize +
|
||||
sizeof(simap_ptr64) +
|
||||
@ -193,6 +195,7 @@ static inline void *simap_force_add_internal(simap_instance *map, const char *ke
|
||||
char *rem_str = (char *)(start_str + 1);
|
||||
strcpy(rem_str, key + 8);
|
||||
}
|
||||
/* XXX: The "padding" gets automagically added by the movement of the arena here(by junk bytes)! */
|
||||
|
||||
/* Update previous with linkage */
|
||||
if(previ != (uint32_t)-1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user