Skip to content

Commit 911d512

Browse files
1 parent b26c0d5 commit 911d512

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎src/tests/Interop/StringMarshalling/UTF8/UTF8TestNative.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ char* utf16_to_utf8(const wchar_t *srcstring)
4343

4444
if (!nc)
4545
{
46+
CoreClrFree(pszUTF8);
4647
return nullptr;
4748
}
4849

@@ -81,9 +82,9 @@ wchar_t* utf8_to_utf16(const char *utf8)
8182

8283
if (!nc)
8384
{
85+
CoreClrFree(wszTextUTF16);
8486
return nullptr;
8587
}
86-
//MultiByteToWideChar do not null terminate the string when cbMultiByte is not -1
8788
wszTextUTF16[nc] = '\0';
8889
return wszTextUTF16;
8990
}
@@ -150,6 +151,7 @@ extern "C" DLL_EXPORT BOOL __cdecl StringBuilderParameterInOut(/*[In,Out] String
150151
if (s[i] != pszTextutf8[i])
151152
{
152153
printf("[in] managed string do not match native string\n");
154+
free_utf8_string(pszTextutf8);
153155
return FALSE;
154156
}
155157
}
@@ -228,6 +230,7 @@ extern "C" DLL_EXPORT BOOL __cdecl TestStructWithUtf8Field(struct FieldWithUtf8
228230
if (pszNative[i] != pszManagedutf8[i])
229231
{
230232
printf("Native and managed string do not match.\n");
233+
free_utf8_string(pszNative);
231234
return FALSE;
232235
}
233236
}
@@ -268,6 +271,7 @@ extern "C" DLL_EXPORT BOOL __cdecl StringParameterRef(/*ref*/ char **s, int inde
268271
if ((*s)[i] != pszTextutf8[i])
269272
{
270273
printf("[in] managed string do not match native string\n");
274+
free_utf8_string(pszTextutf8);
271275
return FALSE;
272276
}
273277
}

0 commit comments

Comments
 (0)