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

Unified Diff: core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp

Issue 430733004: Add more |bpc| value check in GetValidBpc() (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 5 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/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
index 7e80f75269dfe4af41f9f5dae0275ea4fef434ec..6b484cca565b71b27fdef43b5985dd0583e96284 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
@@ -919,15 +919,23 @@ FX_DWORD CPDF_DIBSource::GetValidBpc() const
}
}
}
+ if (bpc != 1 && bpc != 2 && bpc != 4 && bpc != 8 && bpc != 12 && bpc != 16) {
+ bpc = 0;
+ }
+
return bpc;
}
#define NORMALCOLOR_MAX(color, max) (color) > (max) ? (max) : (color) < 0 ? 0 : (color);
void CPDF_DIBSource::TranslateScanline24bpp(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan) const
{
- int max_data = (1 << m_bpc) - 1;
+ FX_DWORD bpc = GetValidBpc();
+ if (bpc == 0) {
+ return;
+ }
+ int max_data = (1 << bpc) - 1;
if (m_bDefaultDecode) {
if (m_Family == PDFCS_DEVICERGB || m_Family == PDFCS_CALRGB) {
- if (m_bpc == 16) {
+ if (bpc == 16) {
Tom Sepez 2014/08/01 20:33:53 nit: someday down the road, this might be better s
Bo Xu 2014/08/01 21:03:01 Changed to switch statement.
FX_LPCBYTE src_pos = src_scan;
for (int col = 0; col < m_Width; col ++) {
*dest_scan++ = src_pos[4];
@@ -935,7 +943,8 @@ void CPDF_DIBSource::TranslateScanline24bpp(FX_LPBYTE dest_scan, FX_LPCBYTE src_
*dest_scan++ = *src_pos;
src_pos += 6;
}
- } else if (m_bpc == 8) {
+ }
Tom Sepez 2014/08/01 20:33:53 nit: this indentation style doesn't match what's i
Bo Xu 2014/08/01 21:03:01 Done.
+ else if (bpc == 8) {
FX_LPCBYTE src_pos = src_scan;
for (int column = 0; column < m_Width; column ++) {
*dest_scan++ = src_pos[2];
@@ -943,10 +952,10 @@ void CPDF_DIBSource::TranslateScanline24bpp(FX_LPBYTE dest_scan, FX_LPCBYTE src_
*dest_scan++ = *src_pos;
src_pos += 3;
}
- } else {
+ }
+ else {
int src_bit_pos = 0;
int dest_byte_pos = 0;
- FX_DWORD bpc = GetValidBpc();
for (int column = 0; column < m_Width; column ++) {
int R = _GetBits8(src_scan, src_bit_pos, bpc);
src_bit_pos += bpc;
@@ -964,7 +973,8 @@ void CPDF_DIBSource::TranslateScanline24bpp(FX_LPBYTE dest_scan, FX_LPCBYTE src_
}
}
return;
- } else if (m_bpc == 8) {
+ }
+ else if (bpc == 8) {
if (m_nComponents == m_pColorSpace->CountComponents())
m_pColorSpace->TranslateImageLine(dest_scan, src_scan, m_Width, m_Width, m_Height,
m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK);
@@ -974,7 +984,7 @@ void CPDF_DIBSource::TranslateScanline24bpp(FX_LPBYTE dest_scan, FX_LPCBYTE src_
CFX_FixedBufGrow<FX_FLOAT, 16> color_values1(m_nComponents);
FX_FLOAT* color_values = color_values1;
FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f;
- if (m_bpc == 8) {
+ if (bpc == 8) {
int src_byte_pos = 0;
int dest_byte_pos = 0;
for (int column = 0; column < m_Width; column ++) {
« 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