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

Side by Side Diff: core/src/fpdftext/fpdf_text_int.cpp

Issue 1142713005: Remove FX_Alloc() null checks now that it can't return NULL. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix missing FX_Alloc2D, check overflow on add, remove unused enum. Created 5 years, 7 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/fpdftext/fpdf_text.cpp ('k') | core/src/fxcodec/codec/fx_codec.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/fpdfapi/fpdf_resource.h" 7 #include "../../include/fpdfapi/fpdf_resource.h"
8 #include "../../include/fpdfapi/fpdf_pageobj.h" 8 #include "../../include/fpdfapi/fpdf_pageobj.h"
9 #include "../../include/fpdftext/fpdf_text.h" 9 #include "../../include/fpdftext/fpdf_text.h"
10 #include "../../include/fpdfapi/fpdf_page.h" 10 #include "../../include/fpdfapi/fpdf_page.h"
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 { 1157 {
1158 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i); 1158 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i);
1159 FX_WCHAR wChar = str.GetAt(i); 1159 FX_WCHAR wChar = str.GetAt(i);
1160 if(!IsControlChar(&Info)) { 1160 if(!IsControlChar(&Info)) {
1161 Info.m_Index = m_TextBuf.GetLength(); 1161 Info.m_Index = m_TextBuf.GetLength();
1162 if (wChar >= 0xFB00 && wChar <= 0xFB06) { 1162 if (wChar >= 0xFB00 && wChar <= 0xFB06) {
1163 FX_LPWSTR pDst = NULL; 1163 FX_LPWSTR pDst = NULL;
1164 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst); 1164 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst);
1165 if (nCount >= 1) { 1165 if (nCount >= 1) {
1166 pDst = FX_Alloc(FX_WCHAR, nCount); 1166 pDst = FX_Alloc(FX_WCHAR, nCount);
1167 if (!pDst) {
1168 return;
1169 }
1170 FX_Unicode_GetNormalization(wChar, pDst); 1167 FX_Unicode_GetNormalization(wChar, pDst);
1171 for (int nIndex = 0; nIndex < nCount; nIndex++) { 1168 for (int nIndex = 0; nIndex < nCount; nIndex++) {
1172 PAGECHAR_INFO Info2 = Info; 1169 PAGECHAR_INFO Info2 = Info;
1173 Info2.m_Unicode = pDst[nIndex]; 1170 Info2.m_Unicode = pDst[nIndex];
1174 Info2.m_Flag = FPDFTEXT_CHAR_PIECE; 1171 Info2.m_Flag = FPDFTEXT_CHAR_PIECE;
1175 m_TextBuf.AppendChar(Info2.m_Unicode); 1172 m_TextBuf.AppendChar(Info2.m_Unicode);
1176 if( !m_ParseOptions.m_bGetCharCodeOnly) { 1173 if( !m_ParseOptions.m_bGetCharCodeOnly) {
1177 m_charList.Add(Info2); 1174 m_charList.Add(Info2);
1178 } 1175 }
1179 } 1176 }
(...skipping 12 matching lines...) Expand all
1192 void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i) 1189 void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i)
1193 { 1190 {
1194 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i); 1191 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i);
1195 if(!IsControlChar(&Info)) { 1192 if(!IsControlChar(&Info)) {
1196 Info.m_Index = m_TextBuf.GetLength(); 1193 Info.m_Index = m_TextBuf.GetLength();
1197 FX_WCHAR wChar = FX_GetMirrorChar(str.GetAt(i), TRUE, FALSE); 1194 FX_WCHAR wChar = FX_GetMirrorChar(str.GetAt(i), TRUE, FALSE);
1198 FX_LPWSTR pDst = NULL; 1195 FX_LPWSTR pDst = NULL;
1199 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst); 1196 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst);
1200 if (nCount >= 1) { 1197 if (nCount >= 1) {
1201 pDst = FX_Alloc(FX_WCHAR, nCount); 1198 pDst = FX_Alloc(FX_WCHAR, nCount);
1202 if (!pDst) {
1203 return;
1204 }
1205 FX_Unicode_GetNormalization(wChar, pDst); 1199 FX_Unicode_GetNormalization(wChar, pDst);
1206 for (int nIndex = 0; nIndex < nCount; nIndex++) { 1200 for (int nIndex = 0; nIndex < nCount; nIndex++) {
1207 PAGECHAR_INFO Info2 = Info; 1201 PAGECHAR_INFO Info2 = Info;
1208 Info2.m_Unicode = pDst[nIndex]; 1202 Info2.m_Unicode = pDst[nIndex];
1209 Info2.m_Flag = FPDFTEXT_CHAR_PIECE; 1203 Info2.m_Flag = FPDFTEXT_CHAR_PIECE;
1210 m_TextBuf.AppendChar(Info2.m_Unicode); 1204 m_TextBuf.AppendChar(Info2.m_Unicode);
1211 if( !m_ParseOptions.m_bGetCharCodeOnly) { 1205 if( !m_ParseOptions.m_bGetCharCodeOnly) {
1212 m_charList.Add(Info2); 1206 m_charList.Add(Info2);
1213 } 1207 }
1214 } 1208 }
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after
2837 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { 2831 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) {
2838 return; 2832 return;
2839 } 2833 }
2840 CPDF_LinkExt* link = NULL; 2834 CPDF_LinkExt* link = NULL;
2841 link = m_LinkList.GetAt(index); 2835 link = m_LinkList.GetAt(index);
2842 if (!link) { 2836 if (!link) {
2843 return ; 2837 return ;
2844 } 2838 }
2845 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); 2839 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects);
2846 } 2840 }
OLDNEW
« no previous file with comments | « core/src/fpdftext/fpdf_text.cpp ('k') | core/src/fxcodec/codec/fx_codec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698