skip to main content

It’s A Size, Jim, But Not As We Know It, Not As We Know It…

  • There’s Klingons on the starboard bow, starboard bow, starboard bow… there’s Klingons on the starboard bow, starboard bow, Jim.

Right, now that you have that tune stuck in your head (just like it is in mine right now), let’s dive right into another little issue that PVS-Studio brought to our attention in the Unreal source.

  • V627 Consider inspecting the expression. The argument of sizeof() is the macro which expands to a number.

Here’s the code that we’re being asked to inspect:-

uint8* Uuid = (uint8*)Data;
if (FMemory::Memcmp(Device->GetDeviceProperties().pipelineCacheUUID, Uuid, sizeof(VK_UUID_SIZE)) == 0)
   bLoaded = true;

Hmm… sizeof(VK_UUID_SIZE). Yep, sounds pretty suspicious to me. It doesn’t take a Starship Captain to figure this out I reckon. VK_UUID_SIZE is defined like this:-

#define VK_UUID_SIZE 16

And used here:-

uint8_t pipelineCacheUUID[VK_UUID_SIZE];

Doh! The mistake is pretty clear now of course. So let’s patch this before someone gets into Tribble… we can do that by changing the code to:-

if (FMemory::Memcmp(Device->GetDeviceProperties().pipelineCacheUUID, Uuid, VK_UUID_SIZE) == 0)

All patched up, quicker than Scotty could fix a faulty warp drive

Credit(s): Robert Troughton (Coconut Lizard),
Evgeniy Ryzhkov (Viva64)
Status: Currently unfixed in 4.15

Facebook Messenger Twitter Pinterest Whatsapp Email
Go to Top