rsync: make blkhash_free() callable with NULL.
authortb <tb@openbsd.org>
Fri, 27 Sep 2024 13:13:14 +0000 (13:13 +0000)
committertb <tb@openbsd.org>
Fri, 27 Sep 2024 13:13:14 +0000 (13:13 +0000)
It is in principle possible that blkhash_free() (which obviously frees
a struct blktab, sigh) is called with NULL. This would lead to a crash.

ok claudio

usr.bin/rsync/blocks.c

index 97a51a2..d1d9b19 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: blocks.c,v 1.26 2024/09/27 13:10:39 tb Exp $ */
+/*     $OpenBSD: blocks.c,v 1.27 2024/09/27 13:13:14 tb Exp $ */
 /*
  * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -125,6 +125,8 @@ blkhash_set(struct blktab *p, const struct blkset *bset)
 void
 blkhash_free(struct blktab *p)
 {
+       if (p == NULL)
+               return;
        free(p->q);
        free(p->blks);
        free(p);