Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(470)

Unified Diff: src/ports/SkFontHost_win_dw.cpp

Issue 128463002: Work around SkString::gEmptyRec->writable_str() is unwritable. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_win_dw.cpp
===================================================================
--- src/ports/SkFontHost_win_dw.cpp (revision 12947)
+++ src/ports/SkFontHost_win_dw.cpp (working copy)
@@ -68,6 +68,15 @@
"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.");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698