Prefast doesn't like my call to WdfObjectAllocateContext

Prefast is unhappy with my call to allocate a context (for a WDFREQUEST,
as it happens). Here is offending code, and the output from Prefast:

WDF_OBJECT_ATTRIBUTES attr;
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE (&attr, MEMORY_OBJECT_HEADER);
LPMEMORY_OBJECT_HEADER rc;
if (!NT_SUCCESS(status = WdfObjectAllocateContext (Request, &attr,
(PVOID *)&rc)))

device.cpp(400) : warning 6386: (PFD)Buffer overrun while writing to
‘rc’: the writable size is ‘1*0’ bytes, but ‘36’ bytes may be written.
Found in function ‘Pci4EvtIoInCallerContext’

Am I missing the boat here? Or is Prefast just being overly
pessimistic? If so, is there anyway to suppress this warning for this line?

Cheers,

– mkj


//
// Michael K. Jones
// Stone Hill Consulting, LLC
// http://www.stonehill.com
//_______________________________________________

Never mind. Didn’t notice I had changed the file while the Prefast
window was up, so the warning wasn’t on the correct line. Sorry about
that…

–mkj

Michael Jones wrote:

Prefast is unhappy with my call to allocate a context (for a WDFREQUEST,
as it happens). Here is offending code, and the output from Prefast:

WDF_OBJECT_ATTRIBUTES attr;
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE (&attr, MEMORY_OBJECT_HEADER);
LPMEMORY_OBJECT_HEADER rc;
if (!NT_SUCCESS(status = WdfObjectAllocateContext (Request, &attr,
(PVOID *)&rc)))

device.cpp(400) : warning 6386: (PFD)Buffer overrun while writing to
‘rc’: the writable size is ‘1*0’ bytes, but ‘36’ bytes may be written.
Found in function ‘Pci4EvtIoInCallerContext’

Am I missing the boat here? Or is Prefast just being overly
pessimistic? If so, is there anyway to suppress this warning for this
line?

Cheers,

– mkj


//
// Michael K. Jones
// Stone Hill Consulting, LLC
// http://www.stonehill.com
//_______________________________________________


//
// Michael K. Jones
// Stone Hill Consulting, LLC
// http://www.stonehill.com
//_______________________________________________