On Mon, Mar 11, 2024 at 12:31:57PM -0700, Josh Steadmon wrote:
Show 31 quoted lines
> > diff --git a/reftable/record.c b/reftable/record.c
> > index 7c86877586..060244337f 100644
> > --- a/reftable/record.c
> > +++ b/reftable/record.c
> > @@ -374,7 +374,7 @@ static int reftable_ref_record_encode(const void *rec, struct string_view s,
> >
> > static int reftable_ref_record_decode(void *rec, struct strbuf key,
> > uint8_t val_type, struct string_view in,
> > - int hash_size)
> > + int hash_size, struct strbuf *scratch)
> > {
> > struct reftable_ref_record *r = rec;
> > struct string_view start = in;
> > @@ -425,13 +425,12 @@ static int reftable_ref_record_decode(void *rec, struct strbuf key,
> > break;
> >
> > case REFTABLE_REF_SYMREF: {
> > - struct strbuf dest = STRBUF_INIT;
> > - int n = decode_string(&dest, in);
> > + int n = decode_string(scratch, in);
> > if (n < 0) {
> > return -1;
> > }
> > string_view_consume(&in, n);
> > - r->value.symref = dest.buf;
> > + r->value.symref = strbuf_detach(scratch, NULL);
> > } break;
>
> I had to dig into this to convince myself that we aren't leaking memory
> here, but IIUC this gets cleaned up eventually by
> reftable_ref_record_release(), right?