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

Unified Diff: chrome/child/pdf_child_init.cc

Issue 903583002: Fix GetFontData calling itself repeatedly until the process crashes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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: chrome/child/pdf_child_init.cc
diff --git a/chrome/child/pdf_child_init.cc b/chrome/child/pdf_child_init.cc
index 338403cc71726ca43f73be21f1f7276d07e0f551..45b403a26e5b05471f6fb47d491328a23edff098 100644
--- a/chrome/child/pdf_child_init.cc
+++ b/chrome/child/pdf_child_init.cc
@@ -31,13 +31,19 @@ HDC WINAPI CreateDCAPatch(LPCSTR driver_name,
return CreateCompatibleDC(NULL);
}
+typedef DWORD (WINAPI* GetFontDataPtr) (HDC hdc,
+ DWORD table,
+ DWORD offset,
+ LPVOID buffer,
+ DWORD length);
+GetFontDataPtr g_original_get_font_data = NULL;
static base::win::IATPatchFunction g_iat_patch_get_font_data;
DWORD WINAPI GetFontDataPatch(HDC hdc,
DWORD table,
DWORD offset,
LPVOID buffer,
DWORD length) {
- int rv = GetFontData(hdc, table, offset, buffer, length);
+ int rv = g_original_get_font_data(hdc, table, offset, buffer, length);
if (rv == GDI_ERROR && hdc) {
HFONT font = static_cast<HFONT>(GetCurrentObject(hdc, OBJ_FONT));
@@ -45,7 +51,7 @@ DWORD WINAPI GetFontDataPatch(HDC hdc,
if (GetObject(font, sizeof(LOGFONT), &logfont)) {
std::vector<char> font_data;
content::ChildThread::Get()->PreCacheFont(logfont);
- rv = GetFontData(hdc, table, offset, buffer, length);
+ rv = g_original_get_font_data(hdc, table, offset, buffer, length);
content::ChildThread::Get()->ReleaseCachedFonts();
}
}
@@ -72,6 +78,8 @@ void InitializePDF() {
CreateDCAPatch);
g_iat_patch_get_font_data.Patch(current_module_name, "gdi32.dll",
"GetFontData", GetFontDataPatch);
+ g_original_get_font_data = reinterpret_cast<GetFontDataPtr>(
+ g_iat_patch_get_font_data.original_function());
#endif // OS_WIN
}
« 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