[6.0] aa7ab50e7 It is OK to call realloc(3) with a NULL pointer

Reza Naghibi reza at naghibi.com
Wed Aug 19 13:17:06 UTC 2020


commit aa7ab50e73f9dd48ab5d615ba303d02087e51e7e
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Apr 18 08:39:40 2019 +0000

    It is OK to call realloc(3) with a NULL pointer

diff --git a/lib/libvmod_directors/shard_cfg.c b/lib/libvmod_directors/shard_cfg.c
index b471e61eb..c2e0a326b 100644
--- a/lib/libvmod_directors/shard_cfg.c
+++ b/lib/libvmod_directors/shard_cfg.c
@@ -380,12 +380,8 @@ shardcfg_backend_expand(const struct backend_reconfig *re)
 	else
 		re->shardd->l_backend <<= 1;
 
-	if (re->shardd->backend)
-		re->shardd->backend = realloc(re->shardd->backend,
-		    re->shardd->l_backend * sizeof *re->shardd->backend);
-	else
-		re->shardd->backend = malloc(
-		    re->shardd->l_backend * sizeof *re->shardd->backend);
+	re->shardd->backend = realloc(re->shardd->backend,
+	    re->shardd->l_backend * sizeof *re->shardd->backend);
 
 	AN(re->shardd->backend);
 }


More information about the varnish-commit mailing list