aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-08 15:53:19 +0000
committerGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-08 15:53:19 +0000
commitfa8afda2500f4c90b52bb18228033abb651bde2d (patch)
tree543beb94a155d04a2c327c0e8370178adee4f296
parenta52209f1628b7cf550b511dc9cdd3273ada5fdea (diff)
Work around SkString::gEmptyRec->writable_str() is unwritable.
-rw-r--r--src/ports/SkFontHost_win_dw.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ports/SkFontHost_win_dw.cpp b/src/ports/SkFontHost_win_dw.cpp
index 00623623b0..a6dd2b169a 100644
--- a/src/ports/SkFontHost_win_dw.cpp
+++ b/src/ports/SkFontHost_win_dw.cpp
@@ -68,6 +68,15 @@ static HRESULT wchar_to_skstring(WCHAR* name, SkString* skname) {
"Could not get length for utf-8 to wchar conversion.");
}
skname->resize(len - 1);
+
+ // TODO: remove after https://code.google.com/p/skia/issues/detail?id=1989 is fixed.
+ // If we resize to 0 then the skname points to gEmptyRec (the unique empty SkString::Rec).
+ // gEmptyRec is static const and on Windows this means the value is in a read only page.
+ // Writing to it in the following call to WideCharToMultiByte will cause an access violation.
+ if (1 == len) {
+ return S_OK;
+ }
+
len = WideCharToMultiByte(CP_UTF8, 0, name, -1, skname->writable_str(), len, NULL, NULL);
if (0 == len) {
HRM(HRESULT_FROM_WIN32(GetLastError()), "Could not convert utf-8 to wchar.");