Skip to content

Commit 49ab022

Browse files
committed
Fix a memory leak when passing an indirect std::string
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 86464a3 commit 49ab022

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Generator/Types/Std/Stdlib.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public override void CSharpMarshalToNative(CSharpMarshalContext ctx)
324324
ctx.Before.WriteLine($@"{qualifiedBasicString}Extensions.{
325325
assign.Name}({varBasicString}, {ctx.Parameter.Name});");
326326
ctx.Return.Write($"{varBasicString}.{Helpers.InstanceIdentifier}");
327-
if (!type.IsPointer())
327+
if (!type.IsPointer() || ctx.Parameter.IsIndirect)
328328
ctx.Cleanup.WriteLine($@"{varBasicString}.Dispose({
329329
(ctx.MarshalKind == MarshalKind.NativeField ? "false" : string.Empty)});");
330330
}

0 commit comments

Comments
 (0)