Elijah Newren <newren@xxxxxxxxx> writes: > Otherwise, this patch looks good to me; thanks! Queued, manually amended, and here is what I have. $ git range-diff @{1}... 1: ca4cc8d182 ! 1: c1ea48a8f7 merge-ort: only do pointer arithmetic for non-empty lists @@ Commit message SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior merge-ort.c:2669:43 in Signed-off-by: Andrzej Hunt <ajrhunt@xxxxxxxxxx> + Reviewed-by: Elijah Newren <newren@xxxxxxxxx> Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> ## merge-ort.c ## @@ merge-ort.c: static void write_tree(struct object_id *result_oid, + size_t hash_size) + { size_t maxlen = 0, extra; - unsigned int nr = versions->nr - offset; +- unsigned int nr = versions->nr - offset; ++ unsigned int nr; struct strbuf buf = STRBUF_INIT; - struct string_list relevant_entries = STRING_LIST_INIT_NODUP; int i; @@ merge-ort.c: static void write_tree(struct object_id *result_oid, - relevant_entries.nr = versions->nr - offset; - QSORT(relevant_entries.items, relevant_entries.nr, tree_entry_order); + assert(offset <= versions->nr); ++ nr = versions->nr - offset; + if (versions->nr) + QSORT(versions->items + offset, nr, tree_entry_order);