Avoid division by zero
authorJeannot Breton <jbreton@nvidia.com>
Wed, 30 Dec 2015 18:35:21 +0000 (12:35 -0600)
committerJeannot Breton <jbreton@nvidia.com>
Wed, 30 Dec 2015 18:35:21 +0000 (12:35 -0600)
external/vulkancts/modules/vulkan/memory/vktMemoryMappingTests.cpp

index a7f7c6f..7034149 100644 (file)
@@ -539,7 +539,7 @@ public:
 
        MemoryObject*                                           allocateRandom  (const DeviceInterface& vkd, VkDevice device, de::Random& rng)
        {
-               const VkDeviceSize              size    = 1 + (rng.getUint64() % ((m_heap.size / MAX_MEMORY_USAGE_DIV) - m_usage - 1));
+               const VkDeviceSize              size    = 1 + (rng.getUint64() % (de::max((m_heap.size / MAX_MEMORY_USAGE_DIV) - m_usage - 1ull, 1ull)));
                const deUint32                  type    = rng.choose<deUint32>(m_memoryTypes.begin(), m_memoryTypes.end());
                MemoryObject* const             object  = new MemoryObject(vkd, device, size, type);