]> xenbits.xensource.com Git - pvdrivers/win/xenvkbd.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:53 +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/xenvkbd/util.h

index f3937095695b45d574e32b9e67cbd2a18752a651..495162e3ea3550ea8a886fd4e694a72f1d2a653d 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