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

Side by Side Diff: core/src/fxge/win32/fx_win32_device.cpp

Issue 383563002: Fix an out-of-boundary issue for wide string (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Add WStringLength function Created 6 years, 5 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 unified diff | Download patch
« no previous file with comments | « core/src/fxcrt/fx_basic_wstring.cpp ('k') | fpdfsdk/src/fpdfdoc.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../../include/fxge/fx_ge.h" 7 #include "../../../include/fxge/fx_ge.h"
8 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ 8 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_
9 #include "../../../include/fxge/fx_ge_win32.h" 9 #include "../../../include/fxge/fx_ge_win32.h"
10 #include <crtdbg.h> 10 #include <crtdbg.h>
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, hFont); 321 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, hFont);
322 int ret = ::GetTextFaceA(m_hDC, 100, facebuf); 322 int ret = ::GetTextFaceA(m_hDC, 100, facebuf);
323 ::SelectObject(m_hDC, hOldFont); 323 ::SelectObject(m_hDC, hOldFont);
324 if (face.EqualNoCase(facebuf)) { 324 if (face.EqualNoCase(facebuf)) {
325 return hFont; 325 return hFont;
326 } 326 }
327 int iCount = sizeof(VariantNames) / sizeof(VariantNames[0]); 327 int iCount = sizeof(VariantNames) / sizeof(VariantNames[0]);
328 for (int i = 0; i < iCount; ++i) { 328 for (int i = 0; i < iCount; ++i) {
329 if (face == VariantNames[i].m_pFaceName) { 329 if (face == VariantNames[i].m_pFaceName) {
330 CFX_WideString wsFace = CFX_WideString::FromLocal(facebuf); 330 CFX_WideString wsFace = CFX_WideString::FromLocal(facebuf);
331 CFX_WideString wsName = CFX_WideString::FromUTF16LE((const unsigned short*)VariantNames[i].m_pVariantName); 331 const unsigned short* pName = (const unsigned short*)VariantNames[i] .m_pVariantName;
332 FX_STRSIZE len = CFX_WideString::WStringLength(pName);
333 CFX_WideString wsName = CFX_WideString::FromUTF16LE(pName, len);
332 if (wsFace == wsName) { 334 if (wsFace == wsName) {
333 return hFont; 335 return hFont;
334 } 336 }
335 } 337 }
336 } 338 }
337 ::DeleteObject(hFont); 339 ::DeleteObject(hFont);
338 if (charset == DEFAULT_CHARSET) { 340 if (charset == DEFAULT_CHARSET) {
339 return NULL; 341 return NULL;
340 } 342 }
341 switch (charset) { 343 switch (charset) {
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 if (m_hDC) { 1198 if (m_hDC) {
1197 SelectObject(m_hDC, m_hOldBitmap); 1199 SelectObject(m_hDC, m_hOldBitmap);
1198 DeleteDC(m_hDC); 1200 DeleteDC(m_hDC);
1199 } 1201 }
1200 if (m_hBitmap) { 1202 if (m_hBitmap) {
1201 DeleteObject(m_hBitmap); 1203 DeleteObject(m_hBitmap);
1202 } 1204 }
1203 delete GetBitmap(); 1205 delete GetBitmap();
1204 } 1206 }
1205 #endif 1207 #endif
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_wstring.cpp ('k') | fpdfsdk/src/fpdfdoc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698