summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Han-Wen Nienhuys <hanwen@google.com>2022-01-20 15:12:06 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2022-01-20 11:31:52 -0800
commit33e922432016f614327bcf5624c084b7c02fe9c3 (patch)
tree790704f2146d071dd15929d545da7f5c40fea2f6
parentreftable: fix resource warning (diff)
downloadtgif-33e922432016f614327bcf5624c084b7c02fe9c3.tar.xz
reftable: all xxx_free() functions accept NULL arguments
This fixes NULL derefs in error paths. Spotted by Coverity. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--reftable/reader.c2
-rw-r--r--reftable/writer.c2
2 files changed, 4 insertions, 0 deletions
diff --git a/reftable/reader.c b/reftable/reader.c
index 35781593a2..272378ed1d 100644
--- a/reftable/reader.c
+++ b/reftable/reader.c
@@ -646,6 +646,8 @@ int reftable_new_reader(struct reftable_reader **p,
void reftable_reader_free(struct reftable_reader *r)
{
+ if (!r)
+ return;
reader_close(r);
reftable_free(r);
}
diff --git a/reftable/writer.c b/reftable/writer.c
index 3ca721e9f6..9fd24fa93c 100644
--- a/reftable/writer.c
+++ b/reftable/writer.c
@@ -150,6 +150,8 @@ void reftable_writer_set_limits(struct reftable_writer *w, uint64_t min,
void reftable_writer_free(struct reftable_writer *w)
{
+ if (!w)
+ return;
reftable_free(w->block);
reftable_free(w);
}