On Wed, Dec 22, 2021 at 11:50 PM Junio C Hamano <gitster@xxxxxxxxx> wrote: > > - memcpy(r->hash_prefix, key.buf, key.len); > > + if (key.len) > > + memcpy(r->hash_prefix, key.buf, key.len); > > r->hash_prefix_len = key.len; > > > > if (val_type == 0) { > > I am not sure why any of these are needed. I'm not sure they are needed, but IMO it's not worth spending brain cycles on deciding either way. Checking the length is always a safe alternative. I would support having a safe_memcpy() that does this check centrally (note how our array_copy() array function also does this check, even if it's not always needed.) -- Han-Wen Nienhuys - Google Munich I work 80%. Don't expect answers from me on Fridays. -- Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Paul Manicle, Halimah DeLaine Prado