For Developers Working With Unreal Engine

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

by
  • 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 🙂

And that’s it for another incredibly short blog… Live Long and Prosper!

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

Analysis, Mr. Spock.

It’s life, Jim, but not as we know it, not as we know it, not as we know it; it’s life, Jim, but not as we know it, not as we know it, Captain.

There’s Klingons on the…. etc[/mk_blockquote]

(by the way, if anyone hasn’t already lost the will to live, this tangible link today was brought to you by VulkanPipeline.cpp – where the above code can be found)


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


Leave a Reply

Your email address will not be published.

*

Latest from ALL

Trash Compactor

We recently found a huge leak in the UE4 garbage collector, particularly

Placating The Natives

In this article we delve into Blueprint Nativization, a relatively new feature
Go to Top
%d bloggers like this: