diff options
Diffstat (limited to 'src/dutil/strutil.cpp')
| -rw-r--r-- | src/dutil/strutil.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
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 | |||
| @@ -920,8 +920,42 @@ LExit: | |||
| 920 | 920 | ||
| 921 | 921 | ||
| 922 | /******************************************************************** | 922 | /******************************************************************** |
| 923 | StrAllocConcatFormattedSecure - allocates or reuses dynamic string | ||
| 924 | memory and adds a formatted string. If the memory needs to be | ||
| 925 | reallocated, calls SecureZeroMemory on original block of memory after | ||
| 926 | it is moved. | ||
| 927 | |||
| 928 | NOTE: caller is responsible for freeing ppwz even if function fails | ||
| 929 | ********************************************************************/ | ||
| 930 | extern "C" HRESULT __cdecl StrAllocConcatFormattedSecure( | ||
| 931 | __deref_out_z LPWSTR* ppwz, | ||
| 932 | __in __format_string LPCWSTR wzFormat, | ||
| 933 | ... | ||
| 934 | ) | ||
| 935 | { | ||
| 936 | Assert(ppwz && wzFormat && *wzFormat); | ||
| 937 | |||
| 938 | HRESULT hr = S_OK; | ||
| 939 | LPWSTR sczFormatted = NULL; | ||
| 940 | va_list args; | ||
| 941 | |||
| 942 | va_start(args, wzFormat); | ||
| 943 | hr = StrAllocFormattedArgsSecure(&sczFormatted, wzFormat, args); | ||
| 944 | va_end(args); | ||
| 945 | ExitOnFailure(hr, "Failed to allocate formatted string"); | ||
| 946 | |||
| 947 | hr = StrAllocConcatSecure(ppwz, sczFormatted, 0); | ||
| 948 | |||
| 949 | LExit: | ||
| 950 | ReleaseStr(sczFormatted); | ||
| 951 | |||
| 952 | return hr; | ||
| 953 | } | ||
| 954 | |||
| 955 | |||
| 956 | /******************************************************************** | ||
| 923 | StrAllocFormattedSecure - allocates or reuses dynamic string memory | 957 | StrAllocFormattedSecure - allocates or reuses dynamic string memory |
| 924 | and formats it. If the memory needs to reallocated, | 958 | and formats it. If the memory needs to be reallocated, |
| 925 | calls SecureZeroMemory on original block of memory after it is moved. | 959 | calls SecureZeroMemory on original block of memory after it is moved. |
| 926 | 960 | ||
| 927 | NOTE: caller is responsible for freeing ppwz even if function fails | 961 | NOTE: caller is responsible for freeing ppwz even if function fails |
