]> xenbits.xensource.com Git - pvdrivers/win/xenhid.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:45:03 +0000 (13:45 +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/xenhid/util.h

index 9ec9d71f50805db09881665cff0f0c04de3d525c..7d304da80d24573cea14a6009b03f00c5c4d09be 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