diff --git a/src/Generator/Generators/CLI/CLIMarshal.cs b/src/Generator/Generators/CLI/CLIMarshal.cs index 70bcb4bf..5d54d878 100644 --- a/src/Generator/Generators/CLI/CLIMarshal.cs +++ b/src/Generator/Generators/CLI/CLIMarshal.cs @@ -180,7 +180,9 @@ namespace CppSharp.Generators.CLI throw new NotSupportedException(string.Format("{0} is not supported yet.", Context.Driver.Options.Encoding.EncodingName)); - return string.Format("clix::marshalString({0})", varName, param); + return string.Format( + "({0} == 0 ? nullptr : clix::marshalString({0}))", + varName, param); } public override bool VisitMemberPointerType(MemberPointerType member,