Skip to content

Commit

Permalink
GetSource/GetText - Copy string rather than using ptr
Browse files Browse the repository at this point in the history
New Mojo IPC implementation uses shared memory rather than a string copy
Attempt to workaround the access violation that's been reported in a few isolated cases
by copying the string rather than using directly.
chromiumembedded/cef@ebee847
  • Loading branch information
amaitland committed Oct 4, 2021
1 parent 7ef2a47 commit 7722881
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion CefSharp.Core.Runtime/Internals/CefStringVisitorAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
#pragma once

#include "Stdafx.h"
#include <msclr\marshal_cppstd.h>
#include <stdlib.h>
#include <string.h>
#include "include/cef_string_visitor.h"

using namespace msclr::interop;

namespace CefSharp
{
namespace Internals
Expand All @@ -30,7 +35,15 @@ namespace CefSharp

virtual void Visit(const CefString& string) override
{
_visitor->Visit(string.empty() ? String::Empty : StringUtils::ToClr(string));
// New Mojo IPC implementation uses shared memory rather than a string copy
// Attempt to workaround the access violation that's been reported in a few isolated cases
// by copying the string rather than using directly.
// https://github.com/chromiumembedded/cef/commit/ebee84755ed14e71388b343231d3a419f1c5c1fd
std::wstring str = string.ToWString();

auto clrString = marshal_as<String^>(str);

_visitor->Visit(clrString);
}

IMPLEMENT_REFCOUNTINGM(CefStringVisitorAdapter);
Expand Down

0 comments on commit 7722881

Please sign in to comment.