From: Owen Smith Date: Mon, 17 Apr 2023 13:24:39 +0000 (+0100) Subject: Check for zero byte allocations X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=8d1e3a5c9fb32067cb26de31a7791c63853657f1;p=pvdrivers%2Fwin%2Fxeniface.git 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 --- diff --git a/src/xeniface/util.h b/src/xeniface/util.h index 71c887d..a278d72 100644 --- a/src/xeniface/util.h +++ b/src/xeniface/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