Skip to content

Commit a1e7c89

Browse files
authored
Merge pull request #3452 from hasumikin/fix/pm_constant_id_list_init_capacity
Allow xcalloc() to return NULL when size is 0 for portability
2 parents 8aa66d0 + 1c32252 commit a1e7c89

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/util/pm_constant_pool.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ pm_constant_id_list_init(pm_constant_id_list_t *list) {
1515
*/
1616
void
1717
pm_constant_id_list_init_capacity(pm_constant_id_list_t *list, size_t capacity) {
18-
list->ids = xcalloc(capacity, sizeof(pm_constant_id_t));
19-
if (list->ids == NULL) abort();
18+
if (capacity) {
19+
list->ids = xcalloc(capacity, sizeof(pm_constant_id_t));
20+
if (list->ids == NULL) abort();
21+
} else {
22+
list->ids = NULL;
23+
}
2024

2125
list->size = 0;
2226
list->capacity = capacity;

0 commit comments

Comments
 (0)