From 94f9303dabb5d28884ac05b179b004f37eae89eb Mon Sep 17 00:00:00 2001
From: Sean Hall <r.sean.hall@gmail.com>
Date: Thu, 14 May 2020 18:31:02 +1000
Subject: Add StrAllocConcatFormattedSecure.

---
 src/dutil/inc/strutil.h |  5 +++++
 src/dutil/strutil.cpp   | 36 +++++++++++++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/src/dutil/inc/strutil.h b/src/dutil/inc/strutil.h
index 1a2ed1d8..c73615aa 100644
--- a/src/dutil/inc/strutil.h
+++ b/src/dutil/inc/strutil.h
@@ -100,6 +100,11 @@ HRESULT __cdecl StrAllocConcatFormatted(
     __in __format_string LPCWSTR wzFormat,
     ...
     );
+HRESULT __cdecl StrAllocConcatFormattedSecure(
+    __deref_out_z LPWSTR* ppwz,
+    __in __format_string LPCWSTR wzFormat,
+    ...
+    );
 HRESULT __cdecl StrAllocFormattedSecure(
     __deref_out_z LPWSTR* ppwz,
     __in __format_string LPCWSTR wzFormat,
diff --git a/src/dutil/strutil.cpp b/src/dutil/strutil.cpp
index 2e5e2f96..4e184c34 100644
--- a/src/dutil/strutil.cpp
+++ b/src/dutil/strutil.cpp
@@ -919,9 +919,43 @@ LExit:
 }
 
 
+/********************************************************************
+StrAllocConcatFormattedSecure - allocates or reuses dynamic string
+memory and adds a formatted string. If the memory needs to be
+reallocated, calls SecureZeroMemory on original block of memory after
+it is moved.
+
+NOTE: caller is responsible for freeing ppwz even if function fails
+********************************************************************/
+extern "C" HRESULT __cdecl StrAllocConcatFormattedSecure(
+    __deref_out_z LPWSTR* ppwz,
+    __in __format_string LPCWSTR wzFormat,
+    ...
+    )
+{
+    Assert(ppwz && wzFormat && *wzFormat);
+
+    HRESULT hr = S_OK;
+    LPWSTR sczFormatted = NULL;
+    va_list args;
+
+    va_start(args, wzFormat);
+    hr = StrAllocFormattedArgsSecure(&sczFormatted, wzFormat, args);
+    va_end(args);
+    ExitOnFailure(hr, "Failed to allocate formatted string");
+
+    hr = StrAllocConcatSecure(ppwz, sczFormatted, 0);
+
+LExit:
+    ReleaseStr(sczFormatted);
+
+    return hr;
+}
+
+
 /********************************************************************
 StrAllocFormattedSecure - allocates or reuses dynamic string memory 
-and formats it. If the memory needs to reallocated, 
+and formats it. If the memory needs to be reallocated,
 calls SecureZeroMemory on original block of memory after it is moved.
 
 NOTE: caller is responsible for freeing ppwz even if function fails
-- 
cgit v1.2.3-55-g6feb