Commit 97823ee2 authored by jam's avatar jam Committed by Commit bot

Fix GetFontData calling itself repeatedly until the process crashes.

It looks like the GetFontData patch for PDFium is only used on XP/Vista now. Previously PDFium was in a separate binary so we were just calling the real GetFontData from chrome_child.dll. That doesn't work anymore, so use the original function pointer.

BUG=455399

Review URL: https://codereview.chromium.org/903583002

Cr-Commit-Position: refs/heads/master@{#314706}
parent d9e23a08
......@@ -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
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment