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

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp

Issue 869343008: Fix an error 'Use-of-uninitialized-value in CPDF_Function::Call' (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 10 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 <limits.h> 7 #include <limits.h>
8 8
9 #include "../../../include/fpdfapi/fpdf_page.h" 9 #include "../../../include/fpdfapi/fpdf_page.h"
10 #include "../../../include/fpdfapi/fpdf_module.h" 10 #include "../../../include/fpdfapi/fpdf_module.h"
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 FX_SAFE_INT32 bitpos = pos; 560 FX_SAFE_INT32 bitpos = pos;
561 bitpos *= m_nBitsPerSample; 561 bitpos *= m_nBitsPerSample;
562 bitpos *= m_nOutputs; 562 bitpos *= m_nOutputs;
563 if (!bitpos.IsValid()) { 563 if (!bitpos.IsValid()) {
564 return FALSE; 564 return FALSE;
565 } 565 }
566 FX_LPCBYTE pSampleData = m_pSampleStream->GetData(); 566 FX_LPCBYTE pSampleData = m_pSampleStream->GetData();
567 if (pSampleData == NULL) { 567 if (pSampleData == NULL) {
568 return FALSE; 568 return FALSE;
569 } 569 }
570 FX_SAFE_INT32 bitpos1 = m_nOutputs - 1 > 0 ? m_nOutputs - 1 : 0; 570 FX_SAFE_INT32 bitpos1 = m_nOutputs - 1 > 0 ? m_nOutputs - 1 : 0;
Tom Sepez 2015/02/12 18:06:46 Looking at the original code, I don't remember why
jun_fang 2015/02/12 18:13:35 This judge is used to ensure 'bitpos.ValueOrDie()
571 bitpos1 *= m_nBitsPerSample; 571 bitpos1 *= m_nBitsPerSample;
572 bitpos1 += bitpos.ValueOrDie(); 572 bitpos1 += bitpos.ValueOrDie();
573 if (!bitpos1.IsValid()) { 573 if (!bitpos1.IsValid()) {
574 return FALSE; 574 return FALSE;
575 } 575 }
576 for (int j = 0; j < m_nOutputs; j ++) { 576 for (int j = 0; j < m_nOutputs; j ++) {
577 FX_DWORD sample = _GetBits32(pSampleData, bitpos.ValueOrDie() + j * m_nB itsPerSample, m_nBitsPerSample); 577 FX_DWORD sample = _GetBits32(pSampleData, bitpos.ValueOrDie() + j * m_nB itsPerSample, m_nBitsPerSample);
578 FX_FLOAT encoded = (FX_FLOAT)sample; 578 FX_FLOAT encoded = (FX_FLOAT)sample;
579 for (int i = 0; i < m_nInputs; i ++) { 579 for (int i = 0; i < m_nInputs; i ++) {
580 if (index[i] == m_pEncodeInfo[i].sizes - 1) { 580 if (index[i] == m_pEncodeInfo[i].sizes - 1) {
581 if (index[i] == 0) { 581 if (index[i] == 0) {
582 encoded = encoded_input[i] * (FX_FLOAT)sample; 582 encoded = encoded_input[i] * (FX_FLOAT)sample;
583 } 583 }
584 } else { 584 } else {
585 FX_SAFE_INT32 bitpos2 = blocksize[i]; 585 FX_SAFE_INT32 bitpos2 = blocksize[i];
586 bitpos2 += 1; 586 bitpos2 += pos;
587 bitpos2 *= m_nOutputs;
588 bitpos2 += j;
587 bitpos2 *= m_nBitsPerSample; 589 bitpos2 *= m_nBitsPerSample;
588 bitpos2 *= m_nOutputs;
589 bitpos2 += bitpos.ValueOrDie();
590 if (!bitpos2.IsValid()) { 590 if (!bitpos2.IsValid()) {
591 return FALSE; 591 return FALSE;
592 } 592 }
593 FX_DWORD sample1 = _GetBits32(pSampleData, bitpos2.ValueOrDie(), m_nBitsPerSample); 593 FX_DWORD sample1 = _GetBits32(pSampleData, bitpos2.ValueOrDie(), m_nBitsPerSample);
594 encoded += (encoded_input[i] - index[i]) * ((FX_FLOAT)sample1 - (FX_FLOAT)sample); 594 encoded += (encoded_input[i] - index[i]) * ((FX_FLOAT)sample1 - (FX_FLOAT)sample);
595 } 595 }
596 } 596 }
597 results[j] = PDF_Interpolate(encoded, 0, (FX_FLOAT)m_SampleMax, 597 results[j] = PDF_Interpolate(encoded, 0, (FX_FLOAT)m_SampleMax,
598 m_pDecodeInfo[j].decode_min, m_pDecodeInfo[ j].decode_max); 598 m_pDecodeInfo[j].decode_min, m_pDecodeInfo[ j].decode_max);
599 } 599 }
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 for (int i = 0; i < m_nOutputs; i ++) { 898 for (int i = 0; i < m_nOutputs; i ++) {
899 if (results[i] < m_pRanges[i * 2]) { 899 if (results[i] < m_pRanges[i * 2]) {
900 results[i] = m_pRanges[i * 2]; 900 results[i] = m_pRanges[i * 2];
901 } else if (results[i] > m_pRanges[i * 2 + 1]) { 901 } else if (results[i] > m_pRanges[i * 2 + 1]) {
902 results[i] = m_pRanges[i * 2 + 1]; 902 results[i] = m_pRanges[i * 2 + 1];
903 } 903 }
904 } 904 }
905 } 905 }
906 return TRUE; 906 return TRUE;
907 } 907 }
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