From 761714b3f6525010a77c258291f40405dc8c43ff Mon Sep 17 00:00:00 2001 From: Murai Takashi Date: Tue, 2 Mar 2021 05:54:23 +0900 Subject: [PATCH] kernel/util: Fix Null pointer passed as 1st argument to memset() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pointed out by Clang Static Analyzer. Change-Id: I8ee4c5d6adac129fc7f3d4117081e0ac26dd2ea0 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3759 Reviewed-by: Jérôme Duval --- src/system/kernel/util/Bitmap.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/util/Bitmap.cpp b/src/system/kernel/util/Bitmap.cpp index 8f47c95e19..4844abb1a1 100644 --- a/src/system/kernel/util/Bitmap.cpp +++ b/src/system/kernel/util/Bitmap.cpp @@ -32,10 +32,10 @@ Bitmap::Bitmap(int bitCount) if (fBits == NULL) { fSize = 0; fInitStatus = B_NO_MEMORY; + } else { + fElementsCount = count; + memset(fBits, 0, sizeof(addr_t) * count); } - - fElementsCount = count; - memset(fBits, 0, sizeof(addr_t) * count); }