From 6f06641bf2ad519921992c3dc64545d6124c390a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Mon, 28 Mar 2022 23:33:40 +0300 Subject: [PATCH] mdbx-tools: handle NULL from memory allocation functions. --- src/mdbx_chk.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mdbx_chk.c b/src/mdbx_chk.c index 62dfcd24..808a088e 100644 --- a/src/mdbx_chk.c +++ b/src/mdbx_chk.c @@ -239,6 +239,8 @@ static void MDBX_PRINTF_ARGS(4, 5) if (!p) { p = mdbx_calloc(1, sizeof(*p)); + if (unlikely(!p)) + return; p->caption = msg; p->pr_next = problems_list; problems_list = p; @@ -616,6 +618,8 @@ static int handle_maindb(const uint64_t record_number, const MDBX_val *key, } name = mdbx_malloc(key->iov_len + 1); + if (unlikely(!name)) + return MDBX_ENOMEM; memcpy(name, key->iov_base, key->iov_len); name[key->iov_len] = '\0'; userdb_count++;