Repository: dotnet/runtime
File: src/coreclr/System.Private.CoreLib/src/System/Exception.CoreCLR.cs (C#)

Code before:
            {
                string message = obj->Message;
                if (string.IsNullOrEmpty(message))
                    message = obj->GetClassName();

                // Allocate the description BSTR.
                return Interop.OleAut32.SysAllocStringLen(message, (uint)message.Length);
            }
            catch (Exception ex)
            {
                *pException = ex;
                return IntPtr.Zero;
            }
        }

        // used by vm
        [UnmanagedCallersOnly]
        internal static unsafe IntPtr GetSourceBstr(Exception* obj, Exception* pException)
        {
            try
            {
                string? source = obj->Source;

                return source != null
                    ? Interop.OleAut32.SysAllocStringLen(source, (uint)source.Length)
                    : IntPtr.Zero;
            }
            catch (Exception ex)
            {
                *pException = ex;
                return IntPtr.Zero;
            }
        }

        private string? GetHelpContext(out uint helpContext)
        {
            helpContext = 0;
            string? helpFile = HelpLink;

            int poundPos, digitEnd;

            if (helpFile is null || (poundPos = helpFile.LastIndexOf('#')) == -1)
            {
                return helpFile;
            }

            for (digitEnd = poundPos + 1; digitEnd < helpFile.Length; digitEnd++)
            {
                if (char.IsWhiteSpace(helpFile[digitEnd]))
                    break;
            }

Review comment (suggestion):
```suggestion
                return Marshal.StringToBSTR(source);
```

Code after:
            {
                string message = obj->Message;
                if (string.IsNullOrEmpty(message))
                    message = obj->GetClassName();

                // Allocate the description BSTR.
                return Marshal.StringToBSTR(message);
            }
            catch (Exception ex)
            {
                *pException = ex;
                return IntPtr.Zero;
            }
        }

        // used by vm
        [UnmanagedCallersOnly]
        internal static unsafe IntPtr GetSourceBstr(Exception* obj, Exception* pException)
        {
            try
            {
                string? source = obj->Source;

                return Marshal.StringToBSTR(source);
            }
            catch (Exception ex)
            {
                *pException = ex;
                return IntPtr.Zero;
            }
        }

        private string? GetHelpContext(out uint helpContext)
        {
            helpContext = 0;
            string? helpFile = HelpLink;

            int poundPos, digitEnd;

            if (helpFile is null || (poundPos = helpFile.LastIndexOf('#')) == -1)
            {
                return helpFile;
            }

            for (digitEnd = poundPos + 1; digitEnd < helpFile.Length; digitEnd++)
            {
                if (char.IsWhiteSpace(helpFile[digitEnd]))
                    break;
            }

            if (uint.TryParse(helpFile.AsSpan(poundPos + 1, digitEnd - poundPos - 1), out helpContext))