GPUOpen-LibrariesAndSDKs / VulkanMemoryAllocator

Easy to integrate Vulkan memory allocation library
MIT License
2.58k stars 351 forks source link

Need help at identifying potential copy-paste bug #405

Closed marrodriguez-EA closed 8 months ago

marrodriguez-EA commented 8 months ago

Hello,

I need some help while trying to identify a potential copy-paste bug. An automated Coverity test raised an issue here, regarding line,

https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/blob/94b1acaef0d1fa6f721559a5f0f3ee31d5efba00/include/vk_mem_alloc.h#L7584

Is this size a copy-paste error? should it be freeSpace1stTo2ndEnd instead? The outer loop reads while (lastOffset < freeSpace1stTo2ndEnd) so I would assume the inner variable needs to match its outer condition (hence, the size -> freeSpace1stTo2ndEnd fix, which is what Coverity proposed originally).

For comparison, L7502 and L7535 are comparing directly against freeSpace2ndTo1stEnd but not against the size variable itself.

Links:

https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/blob/94b1acaef0d1fa6f721559a5f0f3ee31d5efba00/include/vk_mem_alloc.h#L7502 https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/blob/94b1acaef0d1fa6f721559a5f0f3ee31d5efba00/include/vk_mem_alloc.h#L7535

Thanks in advance :D

adam-sawicki-a commented 8 months ago

You are right about this bug. Thank you so much for finding it! I fixed it.

marrodriguez-EA commented 8 months ago

Np! Thanks to you for the quick response :D Keep up the good work!