Skip to content

Commit cc014a3

Browse files
authored
Merge pull request #31 from romanbsd/master
Fix for the uninitialized variables
2 parents 143ad4d + 0680507 commit cc014a3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/art.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,14 @@ static art_node** find_child(art_node *n, unsigned char c) {
176176
bitfield = _mm_movemask_epi8(cmp) & mask;
177177
#else
178178
// Compare the key to all 16 stored keys
179-
unsigned bitfield = 0;
180-
for (short i = 0; i < 16; ++i) {
179+
bitfield = 0;
180+
for (i = 0; i < 16; ++i) {
181181
if (p.p2->keys[i] == c)
182182
bitfield |= (1 << i);
183183
}
184184

185185
// Use a mask to ignore children that don't exist
186+
mask = (1 << n->num_children) - 1;
186187
bitfield &= mask;
187188
#endif
188189
#endif
@@ -354,7 +355,7 @@ art_leaf* art_maximum(art_tree *t) {
354355
}
355356

356357
static art_leaf* make_leaf(const unsigned char *key, int key_len, void *value) {
357-
art_leaf *l = (art_leaf*)malloc(sizeof(art_leaf)+key_len);
358+
art_leaf *l = (art_leaf*)calloc(1, sizeof(art_leaf)+key_len);
358359
l->value = value;
359360
l->key_len = key_len;
360361
memcpy(l->key, key, key_len);

0 commit comments

Comments
 (0)