Skip to content

Commit 76579c8

Browse files
committed
auparse: initialize nvlist on alloc failure
Changed nvlist_create() to always establish a consistent empty-list state before attempting the initial allocation.
1 parent 577ac87 commit 76579c8

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

auparse/nvlist.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,17 @@ static inline int alloc_array(nvlist *l)
4545

4646
void nvlist_create(nvlist *l)
4747
{
48-
if (l) {
49-
if (alloc_array(l))
50-
return;
51-
l->cur = 0;
52-
l->cnt = 0;
53-
l->record = NULL;
54-
l->end = NULL;
55-
}
48+
if (l == NULL)
49+
return;
50+
51+
l->array = NULL;
52+
l->cur = 0;
53+
l->cnt = 0;
54+
l->size = 0;
55+
l->record = NULL;
56+
l->end = NULL;
57+
58+
alloc_array(l);
5659
}
5760

5861
nvnode *nvlist_next(nvlist *l)

0 commit comments

Comments
 (0)