From 64decd48e20f6d20d6f510aa75ab05861fd3d51c Mon Sep 17 00:00:00 2001 From: icy17 <39425646+icy17@users.noreply.github.com> Date: Mon, 29 Apr 2024 13:51:22 +0800 Subject: [PATCH] Fix potential Null pointer dereference in dns-example.c (#1601) --- sample/dns-example.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sample/dns-example.c b/sample/dns-example.c index 87221fdc..7d874ac1 100644 --- a/sample/dns-example.c +++ b/sample/dns-example.c @@ -196,7 +196,17 @@ main(int c, char **v) { #endif event_base = event_base_new(); + if (event_base == NULL) { + fprintf(stderr, "Couldn't create new event_base\n"); + return 1; + } evdns_base = evdns_base_new(event_base, EVDNS_BASE_DISABLE_WHEN_INACTIVE); + if (evdns_base == NULL) { + event_base_free(event_base); + fprintf(stderr, "Couldn't create new evdns_base\n"); + return 1; + } + evdns_set_log_fn(logfn); if (o.servertest) {