Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ jobs:
- name: Prepare vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: 98e7cd3a7ba579efc543f8854af800d033031eae
vcpkgJsonGlob: ./vcpkg.json
runVcpkgInstall: true
env:
Expand Down Expand Up @@ -198,7 +197,6 @@ jobs:
- name: Prepare vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: 98e7cd3a7ba579efc543f8854af800d033031eae
vcpkgJsonGlob: ./vcpkg.json
runVcpkgInstall: true
runVcpkgFormatString: "[`install`, `--recurse`, `--clean-after-build`, `--x-install-root`, `$[env.VCPKG_INSTALLED_DIR]`, `--triplet`, `$[env.VCPKG_DEFAULT_TRIPLET]`, `--x-feature`, `tests`]"
Expand Down
12 changes: 7 additions & 5 deletions src/XMLDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@ struct XMLNode: public XMLElem<xmlNode>
{
if(!d)
return *this;
xmlNodeAddContentLen(d, pcxmlChar(text.data()), int(text.length()));
xmlNodeSetContentLen(d, nullptr, 0);
if(!text.empty())
xmlNodeAddContentLen(d, pcxmlChar(text.data()), int(text.length()));
return *this;
}

Expand Down Expand Up @@ -281,7 +283,7 @@ struct XMLNode: public XMLElem<xmlNode>
}
};

struct XMLDocument: public unique_free_t<xmlDoc>, public XMLNode
struct XMLDocument: public unique_free_d<xmlFreeDoc>, public XMLNode
{
static constexpr std::string_view C14D_ID_1_0 {"http://www.w3.org/TR/2001/REC-xml-c14n-20010315"};
static constexpr std::string_view C14D_ID_1_0_COM {"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"};
Expand All @@ -293,7 +295,7 @@ struct XMLDocument: public unique_free_t<xmlDoc>, public XMLNode
using XMLNode::operator bool;

XMLDocument(element_type *ptr = {}, const XMLName &n = {}) noexcept
: unique_free_t<xmlDoc>(ptr, xmlFreeDoc)
: unique_free_d<xmlFreeDoc>(ptr)
, XMLNode{xmlDocGetRootElement(get())}
{
if(d && !n.name.empty() && n.name != name() && !n.ns.empty() && n.ns != ns())
Expand Down Expand Up @@ -438,8 +440,8 @@ struct XMLDocument: public unique_free_t<xmlDoc>, public XMLNode
{
for(xmlSecSize i = 0; i < xmlSecPtrListGetSize(&(ctx->signedInfoReferences)); ++i)
{
auto *ref = xmlSecDSigReferenceCtxPtr(xmlSecPtrListGetItem(&(ctx->signedInfoReferences), i));
if(ref->status != xmlSecDSigStatusSucceeded)
if(auto *ref = xmlSecDSigReferenceCtxPtr(xmlSecPtrListGetItem(&(ctx->signedInfoReferences), i));
ref && ref->status != xmlSecDSigStatusSucceeded)
{
if(e)
e->addCause(Exception(EXCEPTION_PARAMS("Failed to validate Reference '%s'", ref->uri)));
Expand Down
9 changes: 6 additions & 3 deletions src/util/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ struct free_argument<R (&)(T *)>
using type = T;
};

template <auto D>
using free_argument_t = typename free_argument<decltype(D)>::type;
template <class T>
using unique_free_t = std::unique_ptr<T, void(*)(T*)>;
template <auto D>
using unique_free_d = std::unique_ptr<free_argument_t<D>,free_deleter<D>>;

template<class T, class U>
[[nodiscard]]
Expand All @@ -74,15 +78,14 @@ template<auto D>
[[nodiscard]]
constexpr auto make_unique_ptr(nullptr_t) noexcept
{
using T = typename free_argument<decltype(D)>::type;
return make_unique_ptr<D, T>(nullptr);
return unique_free_d<D>(nullptr);
}

template<auto D>
[[nodiscard]]
constexpr auto make_unique_cast(void *p) noexcept
{
using T = typename free_argument<decltype(D)>::type;
using T = free_argument_t<D>;
return make_unique_ptr<D>(static_cast<T*>(p));
}

Expand Down
Loading