commit 538502d5f09ab609e6362529e4dc91911039e4f0
parent f839c5bcdcb52a7363ff8331d7e286f97d99451d
Author: Frederic Cambus <fred@statdns.com>
Date: Mon, 8 Feb 2021 15:34:29 +0100
Check strdup() return value and error out on failed allocations.
Diffstat:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/statzone.c b/src/statzone.c
@@ -204,6 +204,9 @@ main(int argc, char *argv[])
error("Memory allocation error.");
ds->domain = strdup(domain);
+ if (ds->domain == NULL)
+ error("Memory allocation error.");
+
HASH_ADD_STR(signed_domains, domain, ds);
}
}
@@ -217,6 +220,9 @@ main(int argc, char *argv[])
results.domains++;
free(previous_domain);
previous_domain = strdup(domain);
+ if (previous_domain == NULL)
+ error("Memory allocation error.");
+
if (!strncmp(domain, "xn--", 4))
results.idn++;
}
@@ -235,6 +241,9 @@ main(int argc, char *argv[])
error("Memory allocation error.");
ns->domain = strdup(rdata);
+ if (ns->domain == NULL)
+ error("Memory allocation error.");
+
HASH_ADD_STR(unique_ns, domain, ns);
}
}