[master] 6bdb447b2 Polish smd_init() as suggested by Dridi

Nils Goroll nils.goroll at uplex.de
Wed Sep 29 08:59:07 UTC 2021


commit 6bdb447b2cd6ee81563800ee056369278977ad6b
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed Sep 29 10:54:51 2021 +0200

    Polish smd_init() as suggested by Dridi
    
    Ref #3707

diff --git a/bin/varnishd/storage/storage_debug.c b/bin/varnishd/storage/storage_debug.c
index 23cd5040c..379d97647 100644
--- a/bin/varnishd/storage/storage_debug.c
+++ b/bin/varnishd/storage/storage_debug.c
@@ -69,11 +69,12 @@ smd_init(struct stevedore *parent, int aac, char * const *aav)
 	memcpy(methods, &SML_methods, sizeof *methods);
 	parent->methods = methods;
 
-	av = malloc(sizeof *av * (aac + 1));
+	av = calloc(aac + 1, sizeof *av);
 	AN(av);
 	for (i = 0; i < aac; i++) {
 		if (aav[i] == NULL) {
-			av[ac++] = NULL;
+			AZ(av[ac]);
+			ac++;
 			continue;
 		}
 		if (! strcmp(aav[i], "lessspace")) {
@@ -82,7 +83,7 @@ smd_init(struct stevedore *parent, int aac, char * const *aav)
 		}
 		av[ac++] = strdup(aav[i]);
 	}
-	av[ac] = NULL;
+	AZ(av[ac]);
 
 	sma_stevedore.init(parent, ac, av);
 }


More information about the varnish-commit mailing list