]> xenbits.xensource.com Git - pvdrivers/win/xencons.git/commitdiff
Check for zero byte allocations
authorOwen Smith <owen.smith@cloud.com>
Mon, 17 Apr 2023 13:24:39 +0000 (14:24 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Mon, 22 May 2023 12:43:47 +0000 (13:43 +0100)
Avoid attempting to allocate zero byte buffers, which can lead to
inefficiencies in pool memory usage.

Suggested-by: Matthew Sykes <matthew.sykes@citrix.com>
Signed-off-by: Owen Smith <owen.smith@cloud.com>
src/xencons/util.h

index db520836d1aa70e97136a9d8d1b33dfdde8b8d7f..bea51aa9136225e0c3cd1a47e92323d1d7311261 100644 (file)
@@ -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