From 29ea2c762654768704984bcdf8f7d38af364bf66 Mon Sep 17 00:00:00 2001 From: Pyry Haulos Date: Thu, 4 Aug 2016 11:34:52 -0700 Subject: [PATCH] Fix tcu::Resource leak in draw and dynamic_state tests --- external/vulkancts/modules/vulkan/draw/vktDrawTestCaseUtil.hpp | 6 ++++-- .../modules/vulkan/dynamic_state/vktDynamicStateTestCaseUtil.hpp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawTestCaseUtil.hpp b/external/vulkancts/modules/vulkan/draw/vktDrawTestCaseUtil.hpp index ab60987..c77783d 100644 --- a/external/vulkancts/modules/vulkan/draw/vktDrawTestCaseUtil.hpp +++ b/external/vulkancts/modules/vulkan/draw/vktDrawTestCaseUtil.hpp @@ -33,6 +33,8 @@ #include "gluShaderUtil.hpp" #include "vkPrograms.hpp" +#include "deUniquePtr.hpp" + #include namespace vkt @@ -45,13 +47,13 @@ class ShaderSourceProvider public: static std::string getSource (tcu::Archive& archive, const char* path) { - tcu::Resource *resource = archive.getResource(path); + de::UniquePtr resource(archive.getResource(path)); std::vector readBuffer(resource->getSize() + 1); resource->read(&readBuffer[0], resource->getSize()); readBuffer[readBuffer.size() - 1] = 0; - return reinterpret_cast(&readBuffer[0]); + return std::string(reinterpret_cast(&readBuffer[0])); } }; diff --git a/external/vulkancts/modules/vulkan/dynamic_state/vktDynamicStateTestCaseUtil.hpp b/external/vulkancts/modules/vulkan/dynamic_state/vktDynamicStateTestCaseUtil.hpp index b78799d..7f8ee06 100644 --- a/external/vulkancts/modules/vulkan/dynamic_state/vktDynamicStateTestCaseUtil.hpp +++ b/external/vulkancts/modules/vulkan/dynamic_state/vktDynamicStateTestCaseUtil.hpp @@ -32,6 +32,8 @@ #include "gluShaderUtil.hpp" #include "vkPrograms.hpp" +#include "deUniquePtr.hpp" + #include namespace vkt @@ -54,13 +56,13 @@ class ShaderSourceProvider public: static std::string getSource(tcu::Archive& archive, const char* path) { - tcu::Resource *resource = archive.getResource(path); + de::UniquePtr resource(archive.getResource(path)); std::vector readBuffer(resource->getSize() + 1); resource->read(&readBuffer[0], resource->getSize()); readBuffer[readBuffer.size() - 1] = 0; - return reinterpret_cast(&readBuffer[0]); + return std::string(reinterpret_cast(&readBuffer[0])); } }; -- 2.7.4