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

Unified Diff: core/src/fxcodec/codec/fx_codec_flate.cpp

Issue 509993003: Restrict index not be greater than row_size in TIFF_PredictLine (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Remove index_pre and col_pre Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcodec/codec/fx_codec_flate.cpp
diff --git a/core/src/fxcodec/codec/fx_codec_flate.cpp b/core/src/fxcodec/codec/fx_codec_flate.cpp
index a12fffbe5ced0341c96cbf26a44915ffdedf01ec..1071431ae6bd88eee87aac96719f839a1e3b495b 100644
--- a/core/src/fxcodec/codec/fx_codec_flate.cpp
+++ b/core/src/fxcodec/codec/fx_codec_flate.cpp
@@ -524,13 +524,11 @@ static void TIFF_PredictorEncode(FX_LPBYTE& data_buf, FX_DWORD& data_size,
static void TIFF_PredictLine(FX_LPBYTE dest_buf, int row_size, int BitsPerComponent, int Colors, int Columns)
{
if (BitsPerComponent == 1) {
- int row_bits = BitsPerComponent * Colors * Columns;
+ int row_bits = FX_MIN(BitsPerComponent * Colors * Columns, row_size * 8);
for(int i = 1; i < row_bits; i ++) {
int col = i % 8;
int index = i / 8;
- int index_pre = (col == 0) ? (index - 1) : index;
- int col_pre = (col == 0) ? 8 : col;
- if( ((dest_buf[index] >> (7 - col)) & 1) ^ ((dest_buf[index_pre] >> (8 - col_pre)) & 1) ) {
+ if( ((dest_buf[index] >> (7 - col)) & 1) ^ ((dest_buf[(i-1)/8] >> (7 - (i-1)%8)) & 1) ) {
dest_buf[index] |= 1 << (7 - col);
} else {
dest_buf[index] &= ~(1 << (7 - col));
« 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