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

Side by Side Diff: core/fxcodec/codec/fx_codec_jpx_opj.cpp

Issue 2351623002: Avoid nullptr access in sycc422_to_rgb and sycc420_to_rgb (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | no next file » | 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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 OPJ_UINT32 maxw = img->comps[0].w; 240 OPJ_UINT32 maxw = img->comps[0].w;
241 OPJ_UINT32 maxh = img->comps[0].h; 241 OPJ_UINT32 maxh = img->comps[0].h;
242 FX_SAFE_SIZE_T max_size = maxw; 242 FX_SAFE_SIZE_T max_size = maxw;
243 max_size *= maxh; 243 max_size *= maxh;
244 if (!max_size.IsValid()) 244 if (!max_size.IsValid())
245 return; 245 return;
246 246
247 const int* y = img->comps[0].data; 247 const int* y = img->comps[0].data;
248 const int* cb = img->comps[1].data; 248 const int* cb = img->comps[1].data;
249 const int* cr = img->comps[2].data; 249 const int* cr = img->comps[2].data;
250 if (!y || !cb || !cr)
251 return;
252
250 int *d0, *d1, *d2, *r, *g, *b; 253 int *d0, *d1, *d2, *r, *g, *b;
251 d0 = r = FX_Alloc(int, max_size.ValueOrDie()); 254 d0 = r = FX_Alloc(int, max_size.ValueOrDie());
252 d1 = g = FX_Alloc(int, max_size.ValueOrDie()); 255 d1 = g = FX_Alloc(int, max_size.ValueOrDie());
253 d2 = b = FX_Alloc(int, max_size.ValueOrDie()); 256 d2 = b = FX_Alloc(int, max_size.ValueOrDie());
254 for (uint32_t i = 0; i < maxh; ++i) { 257 for (uint32_t i = 0; i < maxh; ++i) {
255 OPJ_UINT32 j; 258 OPJ_UINT32 j;
256 for (j = 0; j < (maxw & ~static_cast<OPJ_UINT32>(1)); j += 2) { 259 for (j = 0; j < (maxw & ~static_cast<OPJ_UINT32>(1)); j += 2) {
257 sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); 260 sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
258 ++y; 261 ++y;
259 ++r; 262 ++r;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 return; 320 return;
318 int* r = FX_Alloc(int, safeSize.ValueOrDie()); 321 int* r = FX_Alloc(int, safeSize.ValueOrDie());
319 int* g = FX_Alloc(int, safeSize.ValueOrDie()); 322 int* g = FX_Alloc(int, safeSize.ValueOrDie());
320 int* b = FX_Alloc(int, safeSize.ValueOrDie()); 323 int* b = FX_Alloc(int, safeSize.ValueOrDie());
321 int* d0 = r; 324 int* d0 = r;
322 int* d1 = g; 325 int* d1 = g;
323 int* d2 = b; 326 int* d2 = b;
324 const int* y = img->comps[0].data; 327 const int* y = img->comps[0].data;
325 const int* cb = img->comps[1].data; 328 const int* cb = img->comps[1].data;
326 const int* cr = img->comps[2].data; 329 const int* cr = img->comps[2].data;
330 if (!y || !cb || !cr)
331 return;
332
327 const int* ny = nullptr; 333 const int* ny = nullptr;
328 int* nr = nullptr; 334 int* nr = nullptr;
329 int* ng = nullptr; 335 int* ng = nullptr;
330 int* nb = nullptr; 336 int* nb = nullptr;
331 OPJ_UINT32 i = 0; 337 OPJ_UINT32 i = 0;
332 OPJ_UINT32 j = 0; 338 OPJ_UINT32 j = 0;
333 for (i = 0; i < (yh & ~(OPJ_UINT32)1); i += 2) { 339 for (i = 0; i < (yh & ~(OPJ_UINT32)1); i += 2) {
334 ny = y + yw; 340 ny = y + yw;
335 nr = r + yw; 341 nr = r + yw;
336 ng = g + yw; 342 ng = g + yw;
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 bool CCodec_JpxModule::Decode(CJPX_Decoder* pDecoder, 909 bool CCodec_JpxModule::Decode(CJPX_Decoder* pDecoder,
904 uint8_t* dest_data, 910 uint8_t* dest_data,
905 int pitch, 911 int pitch,
906 const std::vector<uint8_t>& offsets) { 912 const std::vector<uint8_t>& offsets) {
907 return pDecoder->Decode(dest_data, pitch, offsets); 913 return pDecoder->Decode(dest_data, pitch, offsets);
908 } 914 }
909 915
910 void CCodec_JpxModule::DestroyDecoder(CJPX_Decoder* pDecoder) { 916 void CCodec_JpxModule::DestroyDecoder(CJPX_Decoder* pDecoder) {
911 delete pDecoder; 917 delete pDecoder;
912 } 918 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698