From e421327725da2fbc713b52ea0e623f67d7bcbcaa Mon Sep 17 00:00:00 2001 From: npm Date: Mon, 28 Nov 2016 09:31:22 -0800 Subject: Replace ASSERT with error return in bmp_read_header The width and compress flag are read, so returning with error is more appropriate than having an ASSERT. BUG=659497 Review-Url: https://codereview.chromium.org/2535863002 --- core/fxcodec/lbmp/fx_bmp.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/core/fxcodec/lbmp/fx_bmp.cpp b/core/fxcodec/lbmp/fx_bmp.cpp index 9105c6ed9c..fb64b36560 100644 --- a/core/fxcodec/lbmp/fx_bmp.cpp +++ b/core/fxcodec/lbmp/fx_bmp.cpp @@ -171,8 +171,10 @@ int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) { return 0; } } - ASSERT(bmp_ptr->width > 0); - ASSERT(bmp_ptr->compress_flag <= BMP_BITFIELDS); + if (bmp_ptr->width <= 0 || bmp_ptr->compress_flag > BMP_BITFIELDS) { + bmp_error(bmp_ptr, "The Bmp File Is Corrupt"); + return 0; + } switch (bmp_ptr->bitCounts) { case 1: case 4: @@ -184,12 +186,8 @@ int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) { return 0; } } - case 32: { - if (bmp_ptr->width <= 0 || bmp_ptr->compress_flag > BMP_BITFIELDS) { - bmp_error(bmp_ptr, "The Bmp File Is Corrupt"); - return 0; - } - } break; + case 32: + break; default: bmp_error(bmp_ptr, "The Bmp File Is Corrupt"); return 0; -- cgit v1.2.3