Fix tcu::Resource leak in draw and dynamic_state tests
authorPyry Haulos <phaulos@google.com>
Thu, 4 Aug 2016 18:34:52 +0000 (11:34 -0700)
committerPyry Haulos <phaulos@google.com>
Thu, 4 Aug 2016 18:34:52 +0000 (11:34 -0700)
external/vulkancts/modules/vulkan/draw/vktDrawTestCaseUtil.hpp
external/vulkancts/modules/vulkan/dynamic_state/vktDynamicStateTestCaseUtil.hpp

index ab60987..c77783d 100644 (file)
@@ -33,6 +33,8 @@
 #include "gluShaderUtil.hpp"
 #include "vkPrograms.hpp"
 
 #include "gluShaderUtil.hpp"
 #include "vkPrograms.hpp"
 
+#include "deUniquePtr.hpp"
+
 #include <map>
 
 namespace vkt
 #include <map>
 
 namespace vkt
@@ -45,13 +47,13 @@ class ShaderSourceProvider
 public:
        static std::string getSource (tcu::Archive& archive, const char* path)
        {
 public:
        static std::string getSource (tcu::Archive& archive, const char* path)
        {
-               tcu::Resource *resource = archive.getResource(path);
+               de::UniquePtr<tcu::Resource> resource(archive.getResource(path));
 
                std::vector<deUint8> readBuffer(resource->getSize() + 1);
                resource->read(&readBuffer[0], resource->getSize());
                readBuffer[readBuffer.size() - 1] = 0;
 
 
                std::vector<deUint8> readBuffer(resource->getSize() + 1);
                resource->read(&readBuffer[0], resource->getSize());
                readBuffer[readBuffer.size() - 1] = 0;
 
-               return reinterpret_cast<const char*>(&readBuffer[0]);
+               return std::string(reinterpret_cast<const char*>(&readBuffer[0]));
        }
 };
 
        }
 };
 
index b78799d..7f8ee06 100644 (file)
@@ -32,6 +32,8 @@
 #include "gluShaderUtil.hpp"
 #include "vkPrograms.hpp"
 
 #include "gluShaderUtil.hpp"
 #include "vkPrograms.hpp"
 
+#include "deUniquePtr.hpp"
+
 #include <map>
 
 namespace vkt
 #include <map>
 
 namespace vkt
@@ -54,13 +56,13 @@ class ShaderSourceProvider
 public:
        static std::string getSource(tcu::Archive& archive, const char* path)
        {
 public:
        static std::string getSource(tcu::Archive& archive, const char* path)
        {
-               tcu::Resource *resource = archive.getResource(path);
+               de::UniquePtr<tcu::Resource> resource(archive.getResource(path));
 
                std::vector<deUint8> readBuffer(resource->getSize() + 1);
                resource->read(&readBuffer[0], resource->getSize());
                readBuffer[readBuffer.size() - 1] = 0;
 
 
                std::vector<deUint8> readBuffer(resource->getSize() + 1);
                resource->read(&readBuffer[0], resource->getSize());
                readBuffer[readBuffer.size() - 1] = 0;
 
-               return reinterpret_cast<const char*>(&readBuffer[0]);
+               return std::string(reinterpret_cast<const char*>(&readBuffer[0]));
        }
 };
 
        }
 };