| 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 "core/fxcodec/jbig2/JBig2_HuffmanTable.h" | 7 #include "core/fxcodec/jbig2/JBig2_HuffmanTable.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 const int low = static_cast<int>(HTLOW); | 58 const int low = static_cast<int>(HTLOW); |
| 59 const int high = static_cast<int>(HTHIGH); | 59 const int high = static_cast<int>(HTHIGH); |
| 60 if (low > high) | 60 if (low > high) |
| 61 return false; | 61 return false; |
| 62 | 62 |
| 63 ExtendBuffers(false); | 63 ExtendBuffers(false); |
| 64 int cur_low = low; | 64 int cur_low = low; |
| 65 do { | 65 do { |
| 66 if ((pStream->readNBits(HTPS, &PREFLEN[NTEMP]) == -1) || | 66 if ((pStream->readNBits(HTPS, &PREFLEN[NTEMP]) == -1) || |
| 67 (pStream->readNBits(HTRS, &RANGELEN[NTEMP]) == -1)) { | 67 (pStream->readNBits(HTRS, &RANGELEN[NTEMP]) == -1) || |
| 68 (static_cast<size_t>(RANGELEN[NTEMP]) >= 8 * sizeof(cur_low))) { |
| 68 return false; | 69 return false; |
| 69 } | 70 } |
| 70 RANGELOW[NTEMP] = cur_low; | 71 RANGELOW[NTEMP] = cur_low; |
| 71 cur_low += (1 << RANGELEN[NTEMP]); | 72 cur_low += (1 << RANGELEN[NTEMP]); |
| 72 ExtendBuffers(true); | 73 ExtendBuffers(true); |
| 73 } while (cur_low < high); | 74 } while (cur_low < high); |
| 74 | 75 |
| 75 if (pStream->readNBits(HTPS, &PREFLEN[NTEMP]) == -1) | 76 if (pStream->readNBits(HTPS, &PREFLEN[NTEMP]) == -1) |
| 76 return false; | 77 return false; |
| 77 | 78 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 size_t size = PREFLEN.size(); | 128 size_t size = PREFLEN.size(); |
| 128 if (NTEMP < size) | 129 if (NTEMP < size) |
| 129 return; | 130 return; |
| 130 | 131 |
| 131 size += 16; | 132 size += 16; |
| 132 ASSERT(NTEMP < size); | 133 ASSERT(NTEMP < size); |
| 133 PREFLEN.resize(size); | 134 PREFLEN.resize(size); |
| 134 RANGELEN.resize(size); | 135 RANGELEN.resize(size); |
| 135 RANGELOW.resize(size); | 136 RANGELOW.resize(size); |
| 136 } | 137 } |
| OLD | NEW |