protocol-caps.c: fix memory leak in send_info()
Fix a memory leak ina2ba162cda
(object-info: support for retrieving object info, 2021-04-20) which appears to have been based on a misunderstanding of how the pkt-line.c API works. There is no need to strdup() input to packet_writer_write(), it's just a printf()-like format function. This fixes a potentially large memory leak, since the number of OID lines the "object-info" call can be arbitrarily large (or a small one if the request is small). This makes t5701-git-serve.sh pass again under SANITIZE=leak, as it did beforea2ba162cda
. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Acked-by: Bruno Albuquerque <bga@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
d94f9b8e90
commit
88682b016d
@ -69,9 +69,10 @@ static void send_info(struct repository *r, struct packet_writer *writer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
packet_writer_write(writer, "%s",
|
packet_writer_write(writer, "%s", send_buffer.buf);
|
||||||
strbuf_detach(&send_buffer, NULL));
|
strbuf_reset(&send_buffer);
|
||||||
}
|
}
|
||||||
|
strbuf_release(&send_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cap_object_info(struct repository *r, struct strvec *keys,
|
int cap_object_info(struct repository *r, struct strvec *keys,
|
||||||
|
Loading…
Reference in New Issue
Block a user