diff --git a/libdrgn/dwarf_index.c b/libdrgn/dwarf_index.c index 8b11182b3..cbdbdaa5b 100644 --- a/libdrgn/dwarf_index.c +++ b/libdrgn/dwarf_index.c @@ -602,15 +602,18 @@ static struct drgn_error *read_cus(struct drgn_dwarf_index *dindex, } } - #pragma omp critical(drgn_read_cus) - if (!err) { - if (compilation_unit_vector_reserve(all_cus, - all_cus->size + cus.size)) { - memcpy(all_cus->data + all_cus->size, cus.data, - cus.size * sizeof(*cus.data)); - all_cus->size += cus.size; - } else { - err = &drgn_enomem; + if (cus.size) { + #pragma omp critical(drgn_read_cus) + if (!err) { + if (compilation_unit_vector_reserve(all_cus, + all_cus->size + cus.size)) { + memcpy(all_cus->data + all_cus->size, + cus.data, + cus.size * sizeof(*cus.data)); + all_cus->size += cus.size; + } else { + err = &drgn_enomem; + } } }