From 9cedc7202c6a447360817e186913f3cd03caccb0 Mon Sep 17 00:00:00 2001 From: GangCao Date: Fri, 4 Jun 2021 15:23:41 -0400 Subject: [PATCH] Util: check the error case of NULL pointer Change-Id: I0be36b584c99de822920b935c34708576617ffc3 Signed-off-by: GangCao Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8176 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Xiaodong Liu Reviewed-by: Changpeng Liu Reviewed-by: Reviewed-by: Shuhei Matsumoto --- examples/util/zipf/zipf.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/util/zipf/zipf.c b/examples/util/zipf/zipf.c index 795cd50543..d62ca2daf2 100644 --- a/examples/util/zipf/zipf.c +++ b/examples/util/zipf/zipf.c @@ -83,6 +83,12 @@ main(int argc, char **argv) zipf = spdk_zipf_create(range, theta, time(NULL)); h = spdk_histogram_data_alloc(); + if (zipf == NULL || h == NULL) { + spdk_zipf_free(&zipf); + spdk_histogram_data_free(h); + printf("out of resource\n"); + return 1; + } for (i = 0; i < count; i++) { spdk_histogram_data_tally(h, spdk_zipf_generate(zipf));