From aca31249ed43050ced1c939ed9d9631e8607819e Mon Sep 17 00:00:00 2001 From: Owen Smith Date: Mon, 17 Apr 2023 14:24:39 +0100 Subject: [PATCH] Check for zero byte allocations Avoid attempting to allocate zero byte buffers, which can lead to inefficiencies in pool memory usage. Suggested-by: Matthew Sykes Signed-off-by: Owen Smith --- src/xenvkbd/util.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/xenvkbd/util.h b/src/xenvkbd/util.h index f393709..495162e 100644 --- a/src/xenvkbd/util.h +++ b/src/xenvkbd/util.h @@ -153,6 +153,9 @@ __AllocatePoolWithTag( __analysis_assume(PoolType == NonPagedPool || PoolType == PagedPool); + if (NumberOfBytes == 0) + return NULL; + #if (_MSC_VER >= 1928) // VS 16.9 (EWDK 20344 or later) Buffer = ExAllocatePoolUninitialized(PoolType, NumberOfBytes, Tag); #else -- 2.39.5