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

Side by Side Diff: core/src/fxge/dib/fx_dib_convert.cpp

Issue 1297713003: Don't bother checking pointers before delete[] and FX_Free(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 5 years, 4 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/fxge/dib/fx_dib_composite.cpp ('k') | core/src/fxge/dib/fx_dib_engine.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_dib.h" 7 #include "../../../include/fxge/fx_dib.h"
8 #include "../../../include/fxge/fx_ge.h" 8 #include "../../../include/fxge/fx_ge.h"
9 #include "../../../include/fxcodec/fx_codec.h" 9 #include "../../../include/fxcodec/fx_codec.h"
10 const FX_DWORD g_dwWinPalette[256] = { 10 const FX_DWORD g_dwWinPalette[256] = {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 195 }
196 } 196 }
197 } 197 }
198 CFX_Palette::CFX_Palette() { 198 CFX_Palette::CFX_Palette() {
199 m_pPalette = NULL; 199 m_pPalette = NULL;
200 m_cLut = NULL; 200 m_cLut = NULL;
201 m_aLut = NULL; 201 m_aLut = NULL;
202 m_lut = 0; 202 m_lut = 0;
203 } 203 }
204 CFX_Palette::~CFX_Palette() { 204 CFX_Palette::~CFX_Palette() {
205 if (m_pPalette) { 205 FX_Free(m_pPalette);
206 FX_Free(m_pPalette); 206 FX_Free(m_cLut);
207 } 207 FX_Free(m_aLut);
208 if (m_cLut) {
209 FX_Free(m_cLut);
210 }
211 if (m_aLut) {
212 FX_Free(m_aLut);
213 }
214 m_lut = 0; 208 m_lut = 0;
215 } 209 }
216 FX_BOOL CFX_Palette::BuildPalette(const CFX_DIBSource* pBitmap, int pal_type) { 210 FX_BOOL CFX_Palette::BuildPalette(const CFX_DIBSource* pBitmap, int pal_type) {
217 if (pBitmap == NULL) { 211 if (pBitmap == NULL) {
218 return FALSE; 212 return FALSE;
219 } 213 }
220 if (m_pPalette != NULL) { 214 FX_Free(m_pPalette);
221 FX_Free(m_pPalette);
222 }
223 m_pPalette = FX_Alloc(FX_DWORD, 256); 215 m_pPalette = FX_Alloc(FX_DWORD, 256);
224 int bpp = pBitmap->GetBPP() / 8; 216 int bpp = pBitmap->GetBPP() / 8;
225 int width = pBitmap->GetWidth(); 217 int width = pBitmap->GetWidth();
226 int height = pBitmap->GetHeight(); 218 int height = pBitmap->GetHeight();
227 if (m_cLut) { 219 FX_Free(m_cLut);
228 FX_Free(m_cLut); 220 m_cLut = NULL;
229 m_cLut = NULL; 221 FX_Free(m_aLut);
230 } 222 m_aLut = NULL;
231 if (m_aLut) {
232 FX_Free(m_aLut);
233 m_aLut = NULL;
234 }
235 m_cLut = FX_Alloc(FX_DWORD, 4096); 223 m_cLut = FX_Alloc(FX_DWORD, 4096);
236 m_aLut = FX_Alloc(FX_DWORD, 4096); 224 m_aLut = FX_Alloc(FX_DWORD, 4096);
237 int row, col; 225 int row, col;
238 m_lut = 0; 226 m_lut = 0;
239 for (row = 0; row < height; row++) { 227 for (row = 0; row < height; row++) {
240 uint8_t* scan_line = (uint8_t*)pBitmap->GetScanline(row); 228 uint8_t* scan_line = (uint8_t*)pBitmap->GetScanline(row);
241 for (col = 0; col < width; col++) { 229 for (col = 0; col < width; col++) {
242 uint8_t* src_port = scan_line + col * bpp; 230 uint8_t* src_port = scan_line + col * bpp;
243 FX_DWORD b = src_port[0] & 0xf0; 231 FX_DWORD b = src_port[0] & 0xf0;
244 FX_DWORD g = src_port[1] & 0xf0; 232 FX_DWORD g = src_port[1] & 0xf0;
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 pSrcAlpha = NULL; 1116 pSrcAlpha = NULL;
1129 } 1117 }
1130 if (!ret) { 1118 if (!ret) {
1131 delete pClone; 1119 delete pClone;
1132 return NULL; 1120 return NULL;
1133 } 1121 }
1134 FX_DWORD* pal_8bpp = NULL; 1122 FX_DWORD* pal_8bpp = NULL;
1135 ret = ConvertBuffer(dest_format, pClone->GetBuffer(), pClone->GetPitch(), 1123 ret = ConvertBuffer(dest_format, pClone->GetBuffer(), pClone->GetPitch(),
1136 m_Width, m_Height, this, 0, 0, pal_8bpp, pIccTransform); 1124 m_Width, m_Height, this, 0, 0, pal_8bpp, pIccTransform);
1137 if (!ret) { 1125 if (!ret) {
1138 if (pal_8bpp) { 1126 FX_Free(pal_8bpp);
1139 FX_Free(pal_8bpp);
1140 }
1141 delete pClone; 1127 delete pClone;
1142 return NULL; 1128 return NULL;
1143 } 1129 }
1144 if (pal_8bpp) { 1130 if (pal_8bpp) {
1145 pClone->CopyPalette(pal_8bpp); 1131 pClone->CopyPalette(pal_8bpp);
1146 FX_Free(pal_8bpp); 1132 FX_Free(pal_8bpp);
1147 pal_8bpp = NULL; 1133 pal_8bpp = NULL;
1148 } 1134 }
1149 return pClone; 1135 return pClone;
1150 } 1136 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 } else { 1194 } else {
1209 pAlphaMask = m_pAlphaMask; 1195 pAlphaMask = m_pAlphaMask;
1210 } 1196 }
1211 } 1197 }
1212 } 1198 }
1213 FX_BOOL ret = FALSE; 1199 FX_BOOL ret = FALSE;
1214 FX_DWORD* pal_8bpp = NULL; 1200 FX_DWORD* pal_8bpp = NULL;
1215 ret = ConvertBuffer(dest_format, dest_buf, dest_pitch, m_Width, m_Height, 1201 ret = ConvertBuffer(dest_format, dest_buf, dest_pitch, m_Width, m_Height,
1216 this, 0, 0, pal_8bpp, pIccTransform); 1202 this, 0, 0, pal_8bpp, pIccTransform);
1217 if (!ret) { 1203 if (!ret) {
1218 if (pal_8bpp) { 1204 FX_Free(pal_8bpp);
1219 FX_Free(pal_8bpp);
1220 }
1221 if (pAlphaMask != m_pAlphaMask) { 1205 if (pAlphaMask != m_pAlphaMask) {
1222 delete pAlphaMask; 1206 delete pAlphaMask;
1223 } 1207 }
1224 if (dest_buf) { 1208 FX_Free(dest_buf);
1225 FX_Free(dest_buf);
1226 }
1227 return FALSE; 1209 return FALSE;
1228 } 1210 }
1229 if (m_pAlphaMask && pAlphaMask != m_pAlphaMask) { 1211 if (m_pAlphaMask && pAlphaMask != m_pAlphaMask) {
1230 delete m_pAlphaMask; 1212 delete m_pAlphaMask;
1231 } 1213 }
1232 m_pAlphaMask = pAlphaMask; 1214 m_pAlphaMask = pAlphaMask;
1233 if (m_pPalette) { 1215 FX_Free(m_pPalette);
1234 FX_Free(m_pPalette);
1235 }
1236 m_pPalette = pal_8bpp; 1216 m_pPalette = pal_8bpp;
1237 if (!m_bExtBuf) { 1217 if (!m_bExtBuf) {
1238 FX_Free(m_pBuffer); 1218 FX_Free(m_pBuffer);
1239 } 1219 }
1240 m_bExtBuf = FALSE; 1220 m_bExtBuf = FALSE;
1241 m_pBuffer = dest_buf; 1221 m_pBuffer = dest_buf;
1242 m_bpp = (uint8_t)dest_format; 1222 m_bpp = (uint8_t)dest_format;
1243 m_AlphaFlag = (uint8_t)(dest_format >> 8); 1223 m_AlphaFlag = (uint8_t)(dest_format >> 8);
1244 m_Pitch = dest_pitch; 1224 m_Pitch = dest_pitch;
1245 return TRUE; 1225 return TRUE;
1246 } 1226 }
OLDNEW
« no previous file with comments | « core/src/fxge/dib/fx_dib_composite.cpp ('k') | core/src/fxge/dib/fx_dib_engine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698