fix memory leak at creation of curl connection in azure sdk

This commit is contained in:
Anton Popov 2023-02-03 20:06:02 +00:00
parent cdbe145bc1
commit e9f80c650a
3 changed files with 42 additions and 26 deletions

2
contrib/azure vendored

@ -1 +1 @@
Subproject commit e4fcdfc81e337e589ce231a452dcc280fcbb3f99
Subproject commit 096049bf24fffafcaccc132b9367694532716731

View File

@ -0,0 +1,41 @@
#include <azure/storage/blobs/blob_options.hpp>
#include <string>
#include <vector>
#include <Common/logger_useful.h>
#include "config.h"
#if USE_AZURE_BLOB_STORAGE
#include <azure/storage/blobs.hpp>
#include <azure/storage/common/internal/xml_wrapper.hpp>
#include <azure/storage/blobs/blob_container_client.hpp>
#include <gtest/gtest.h>
TEST(AzureXMLWrapper, TestLeak)
{
std::string str = "<hello>world</hello>";
Azure::Storage::_internal::XmlReader reader(str.c_str(), str.length());
Azure::Storage::_internal::XmlReader reader2(std::move(reader));
Azure::Storage::_internal::XmlReader reader3 = std::move(reader2);
reader3.Read();
}
TEST(AzureBlobContainerClient, CurlMemoryLeak)
{
using Azure::Storage::Blobs::BlobContainerClient;
using Azure::Storage::Blobs::BlobClientOptions;
static constexpr auto unavailable_url = "http://unavailable:19999/bucket";
static constexpr auto container = "container";
BlobClientOptions options;
options.Retry.MaxRetries = 0;
auto client = std::make_unique<BlobContainerClient>(BlobContainerClient::CreateFromConnectionString(unavailable_url, container, options));
EXPECT_THROW({ client->ListBlobs(); }, Azure::Core::Http::TransportException);
}
#endif

View File

@ -1,25 +0,0 @@
#include <string>
#include <vector>
#include <Common/logger_useful.h>
#include "config.h"
#if USE_AZURE_BLOB_STORAGE
#include <azure/storage/blobs.hpp>
#include <azure/storage/common/internal/xml_wrapper.hpp>
#include <gtest/gtest.h>
TEST(AzureXMLWrapper, TestLeak)
{
std::string str = "<hello>world</hello>";
Azure::Storage::_internal::XmlReader reader(str.c_str(), str.length());
Azure::Storage::_internal::XmlReader reader2(std::move(reader));
Azure::Storage::_internal::XmlReader reader3 = std::move(reader2);
reader3.Read();
}
#endif