mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
reftable/writer: fix memory leak when padded_write() fails
In reftable/writer.c:padded_write(), if w->writer failed, zeroed allocated in `reftable_calloc` will leak. w->writer could be `reftable_write_data` in reftable/stack.c, and could fail due to some write error. Simply add reftable_free(zeroed) will solve this problem. Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
d50a5e8939
commit
c8e752eaef
@@ -57,8 +57,10 @@ static int padded_write(struct reftable_writer *w, uint8_t *data, size_t len,
|
||||
return -1;
|
||||
|
||||
n = w->write(w->write_arg, zeroed, w->pending_padding);
|
||||
if (n < 0)
|
||||
if (n < 0) {
|
||||
reftable_free(zeroed);
|
||||
return n;
|
||||
}
|
||||
|
||||
w->pending_padding = 0;
|
||||
reftable_free(zeroed);
|
||||
|
||||
Reference in New Issue
Block a user