OLD | NEW |
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_module.h" | 9 #include "../../../include/fpdfapi/fpdf_module.h" |
10 #include "../../../include/fpdfapi/fpdf_page.h" | 10 #include "../../../include/fpdfapi/fpdf_page.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } else if (m_Operators[i] == (FX_LPVOID)PSOP_CONST) { | 70 } else if (m_Operators[i] == (FX_LPVOID)PSOP_CONST) { |
71 FX_Free((FX_FLOAT*)m_Operators[i + 1]); | 71 FX_Free((FX_FLOAT*)m_Operators[i + 1]); |
72 i ++; | 72 i ++; |
73 } | 73 } |
74 } | 74 } |
75 } | 75 } |
76 FX_BOOL CPDF_PSProc::Execute(CPDF_PSEngine* pEngine) | 76 FX_BOOL CPDF_PSProc::Execute(CPDF_PSEngine* pEngine) |
77 { | 77 { |
78 int size = m_Operators.GetSize(); | 78 int size = m_Operators.GetSize(); |
79 for (int i = 0; i < size; i ++) { | 79 for (int i = 0; i < size; i ++) { |
80 PDF_PSOP op = (PDF_PSOP)(FX_UINTPTR)m_Operators[i]; | 80 PDF_PSOP op = (PDF_PSOP)(uintptr_t)m_Operators[i]; |
81 if (op == PSOP_PROC) { | 81 if (op == PSOP_PROC) { |
82 i ++; | 82 i ++; |
83 } else if (op == PSOP_CONST) { | 83 } else if (op == PSOP_CONST) { |
84 pEngine->Push(*(FX_FLOAT*)m_Operators[i + 1]); | 84 pEngine->Push(*(FX_FLOAT*)m_Operators[i + 1]); |
85 i ++; | 85 i ++; |
86 } else if (op == PSOP_IF) { | 86 } else if (op == PSOP_IF) { |
87 if (i < 2 || m_Operators[i - 2] != (FX_LPVOID)PSOP_PROC) { | 87 if (i < 2 || m_Operators[i - 2] != (FX_LPVOID)PSOP_PROC) { |
88 return FALSE; | 88 return FALSE; |
89 } | 89 } |
90 if ((int)pEngine->Pop()) { | 90 if ((int)pEngine->Pop()) { |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 m_pSampleStream = new CPDF_StreamAcc; | 485 m_pSampleStream = new CPDF_StreamAcc; |
486 m_pSampleStream->LoadAllData(pStream, FALSE); | 486 m_pSampleStream->LoadAllData(pStream, FALSE); |
487 m_pEncodeInfo = FX_Alloc(SampleEncodeInfo, m_nInputs); | 487 m_pEncodeInfo = FX_Alloc(SampleEncodeInfo, m_nInputs); |
488 int i; | 488 int i; |
489 FX_DWORD nTotalSamples = 1; | 489 FX_DWORD nTotalSamples = 1; |
490 for (i = 0; i < m_nInputs; i ++) { | 490 for (i = 0; i < m_nInputs; i ++) { |
491 m_pEncodeInfo[i].sizes = pSize ? pSize->GetInteger(i) : 0; | 491 m_pEncodeInfo[i].sizes = pSize ? pSize->GetInteger(i) : 0; |
492 if (!pSize && i == 0) { | 492 if (!pSize && i == 0) { |
493 m_pEncodeInfo[i].sizes = pDict->GetInteger(FX_BSTRC("Size")); | 493 m_pEncodeInfo[i].sizes = pDict->GetInteger(FX_BSTRC("Size")); |
494 } | 494 } |
495 if (nTotalSamples > 0 && (FX_UINT32)(m_pEncodeInfo[i].sizes) > UINT_MAX
/ nTotalSamples) { | 495 if (nTotalSamples > 0 && (uint32_t)(m_pEncodeInfo[i].sizes) > UINT_MAX /
nTotalSamples) { |
496 return FALSE; | 496 return FALSE; |
497 } | 497 } |
498 nTotalSamples *= m_pEncodeInfo[i].sizes; | 498 nTotalSamples *= m_pEncodeInfo[i].sizes; |
499 if (pEncode) { | 499 if (pEncode) { |
500 m_pEncodeInfo[i].encode_min = pEncode->GetFloat(i * 2); | 500 m_pEncodeInfo[i].encode_min = pEncode->GetFloat(i * 2); |
501 m_pEncodeInfo[i].encode_max = pEncode->GetFloat(i * 2 + 1); | 501 m_pEncodeInfo[i].encode_max = pEncode->GetFloat(i * 2 + 1); |
502 } else { | 502 } else { |
503 m_pEncodeInfo[i].encode_min = 0; | 503 m_pEncodeInfo[i].encode_min = 0; |
504 if (m_pEncodeInfo[i].sizes == 1) { | 504 if (m_pEncodeInfo[i].sizes == 1) { |
505 m_pEncodeInfo[i].encode_max = 1; | 505 m_pEncodeInfo[i].encode_max = 1; |
506 } else { | 506 } else { |
507 m_pEncodeInfo[i].encode_max = (FX_FLOAT)m_pEncodeInfo[i].sizes -
1; | 507 m_pEncodeInfo[i].encode_max = (FX_FLOAT)m_pEncodeInfo[i].sizes -
1; |
508 } | 508 } |
509 } | 509 } |
510 } | 510 } |
511 if (nTotalSamples > 0 && m_nBitsPerSample > UINT_MAX / nTotalSamples) { | 511 if (nTotalSamples > 0 && m_nBitsPerSample > UINT_MAX / nTotalSamples) { |
512 return FALSE; | 512 return FALSE; |
513 } | 513 } |
514 nTotalSamples *= m_nBitsPerSample; | 514 nTotalSamples *= m_nBitsPerSample; |
515 if (nTotalSamples > 0 && ((FX_UINT32)m_nOutputs) > UINT_MAX / nTotalSamples)
{ | 515 if (nTotalSamples > 0 && ((uint32_t)m_nOutputs) > UINT_MAX / nTotalSamples)
{ |
516 return FALSE; | 516 return FALSE; |
517 } | 517 } |
518 nTotalSamples *= m_nOutputs; | 518 nTotalSamples *= m_nOutputs; |
519 if (nTotalSamples == 0 || m_pSampleStream->GetSize() * 8 < nTotalSamples) { | 519 if (nTotalSamples == 0 || m_pSampleStream->GetSize() * 8 < nTotalSamples) { |
520 return FALSE; | 520 return FALSE; |
521 } | 521 } |
522 m_pDecodeInfo = FX_Alloc(SampleDecodeInfo, m_nOutputs); | 522 m_pDecodeInfo = FX_Alloc(SampleDecodeInfo, m_nOutputs); |
523 for (i = 0; i < m_nOutputs; i ++) { | 523 for (i = 0; i < m_nOutputs; i ++) { |
524 if (pDecode) { | 524 if (pDecode) { |
525 m_pDecodeInfo[i].decode_min = pDecode->GetFloat(2 * i); | 525 m_pDecodeInfo[i].decode_min = pDecode->GetFloat(2 * i); |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 for (int i = 0; i < m_nOutputs; i ++) { | 896 for (int i = 0; i < m_nOutputs; i ++) { |
897 if (results[i] < m_pRanges[i * 2]) { | 897 if (results[i] < m_pRanges[i * 2]) { |
898 results[i] = m_pRanges[i * 2]; | 898 results[i] = m_pRanges[i * 2]; |
899 } else if (results[i] > m_pRanges[i * 2 + 1]) { | 899 } else if (results[i] > m_pRanges[i * 2 + 1]) { |
900 results[i] = m_pRanges[i * 2 + 1]; | 900 results[i] = m_pRanges[i * 2 + 1]; |
901 } | 901 } |
902 } | 902 } |
903 } | 903 } |
904 return TRUE; | 904 return TRUE; |
905 } | 905 } |
OLD | NEW |