This patch mainly suppresses a compiler warning. The application
will still crash.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer.
*/
+#define _GNU_SOURCE
+
+#include <assert.h>
+#include <stdio.h>
+
#include "dnsmasq.h"
#ifdef HAVE_ISC_READER
static struct isc_dhcp_lease* dhcp_lease_new(const char* hostname) {
struct isc_dhcp_lease* lease = whine_malloc(sizeof(*lease));
+ if (!lease)
+ return NULL;
lease->name = strdup(hostname);
if (daemon->domain_suffix) {
- asprintf(&lease->fqdn, "%s.%s", hostname, daemon->domain_suffix);
+ int r = asprintf(&lease->fqdn, "%s.%s", hostname, daemon->domain_suffix);
+
+ // Handle OOM
+ if (r < 0) {
+ free(lease);
+ return NULL;
+ }
}
lease->expires = 0;
lease->next = NULL;
// and append it to the list.
if (!lease) {
lease = dhcp_lease_new(hostname);
+ assert(lease);
lease->next = leases;
leases = lease;