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

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

Issue 1145843005: Revert "Remove FX_Alloc() null checks now that it can't return NULL." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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 }
1167 FX_Unicode_GetNormalization(wChar, pDst); 1170 FX_Unicode_GetNormalization(wChar, pDst);
1168 for (int nIndex = 0; nIndex < nCount; nIndex++) { 1171 for (int nIndex = 0; nIndex < nCount; nIndex++) {
1169 PAGECHAR_INFO Info2 = Info; 1172 PAGECHAR_INFO Info2 = Info;
1170 Info2.m_Unicode = pDst[nIndex]; 1173 Info2.m_Unicode = pDst[nIndex];
1171 Info2.m_Flag = FPDFTEXT_CHAR_PIECE; 1174 Info2.m_Flag = FPDFTEXT_CHAR_PIECE;
1172 m_TextBuf.AppendChar(Info2.m_Unicode); 1175 m_TextBuf.AppendChar(Info2.m_Unicode);
1173 if( !m_ParseOptions.m_bGetCharCodeOnly) { 1176 if( !m_ParseOptions.m_bGetCharCodeOnly) {
1174 m_charList.Add(Info2); 1177 m_charList.Add(Info2);
1175 } 1178 }
1176 } 1179 }
(...skipping 12 matching lines...) Expand all
1189 void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i) 1192 void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i)
1190 { 1193 {
1191 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i); 1194 PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i);
1192 if(!IsControlChar(&Info)) { 1195 if(!IsControlChar(&Info)) {
1193 Info.m_Index = m_TextBuf.GetLength(); 1196 Info.m_Index = m_TextBuf.GetLength();
1194 FX_WCHAR wChar = FX_GetMirrorChar(str.GetAt(i), TRUE, FALSE); 1197 FX_WCHAR wChar = FX_GetMirrorChar(str.GetAt(i), TRUE, FALSE);
1195 FX_LPWSTR pDst = NULL; 1198 FX_LPWSTR pDst = NULL;
1196 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst); 1199 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst);
1197 if (nCount >= 1) { 1200 if (nCount >= 1) {
1198 pDst = FX_Alloc(FX_WCHAR, nCount); 1201 pDst = FX_Alloc(FX_WCHAR, nCount);
1202 if (!pDst) {
1203 return;
1204 }
1199 FX_Unicode_GetNormalization(wChar, pDst); 1205 FX_Unicode_GetNormalization(wChar, pDst);
1200 for (int nIndex = 0; nIndex < nCount; nIndex++) { 1206 for (int nIndex = 0; nIndex < nCount; nIndex++) {
1201 PAGECHAR_INFO Info2 = Info; 1207 PAGECHAR_INFO Info2 = Info;
1202 Info2.m_Unicode = pDst[nIndex]; 1208 Info2.m_Unicode = pDst[nIndex];
1203 Info2.m_Flag = FPDFTEXT_CHAR_PIECE; 1209 Info2.m_Flag = FPDFTEXT_CHAR_PIECE;
1204 m_TextBuf.AppendChar(Info2.m_Unicode); 1210 m_TextBuf.AppendChar(Info2.m_Unicode);
1205 if( !m_ParseOptions.m_bGetCharCodeOnly) { 1211 if( !m_ParseOptions.m_bGetCharCodeOnly) {
1206 m_charList.Add(Info2); 1212 m_charList.Add(Info2);
1207 } 1213 }
1208 } 1214 }
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after
2831 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { 2837 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) {
2832 return; 2838 return;
2833 } 2839 }
2834 CPDF_LinkExt* link = NULL; 2840 CPDF_LinkExt* link = NULL;
2835 link = m_LinkList.GetAt(index); 2841 link = m_LinkList.GetAt(index);
2836 if (!link) { 2842 if (!link) {
2837 return ; 2843 return ;
2838 } 2844 }
2839 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); 2845 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects);
2840 } 2846 }
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