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

Side by Side Diff: core/src/fxcodec/lbmp/fx_bmp.cpp

Issue 1144683002: Merge to XFA: Abort on OOM by default in FX_Alloc(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Suppress failing tests Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « core/src/fxcodec/codec/fx_codec.cpp ('k') | core/src/fxcodec/lgif/fx_gif.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "fx_bmp.h" 7 #include "fx_bmp.h"
8 FX_DWORD _GetDWord_LSBFirst(FX_LPBYTE p) 8 FX_DWORD _GetDWord_LSBFirst(FX_LPBYTE p)
9 { 9 {
10 return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); 10 return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 dst_size = dst_pos; 875 dst_size = dst_pos;
876 } 876 }
877 FX_BOOL _bmp_encode_image( bmp_compress_struct_p bmp_ptr, FX_LPBYTE& dst_buf, FX _DWORD& dst_size ) 877 FX_BOOL _bmp_encode_image( bmp_compress_struct_p bmp_ptr, FX_LPBYTE& dst_buf, FX _DWORD& dst_size )
878 { 878 {
879 FX_DWORD head_size = sizeof(BmpFileHeader) + sizeof(BmpInfoHeader); 879 FX_DWORD head_size = sizeof(BmpFileHeader) + sizeof(BmpInfoHeader);
880 FX_DWORD pal_size = sizeof(FX_DWORD) * bmp_ptr->pal_num; 880 FX_DWORD pal_size = sizeof(FX_DWORD) * bmp_ptr->pal_num;
881 if (bmp_ptr->info_header.biClrUsed > 0 && bmp_ptr->info_header.biClrUsed < b mp_ptr->pal_num) { 881 if (bmp_ptr->info_header.biClrUsed > 0 && bmp_ptr->info_header.biClrUsed < b mp_ptr->pal_num) {
882 pal_size = sizeof(FX_DWORD) * bmp_ptr->info_header.biClrUsed; 882 pal_size = sizeof(FX_DWORD) * bmp_ptr->info_header.biClrUsed;
883 } 883 }
884 dst_size = head_size + sizeof(FX_DWORD) * bmp_ptr->pal_num; 884 dst_size = head_size + sizeof(FX_DWORD) * bmp_ptr->pal_num;
885 dst_buf = FX_AllocNL(FX_BYTE, dst_size); 885 dst_buf = FX_TryAlloc(FX_BYTE, dst_size);
886 if (dst_buf == NULL) { 886 if (dst_buf == NULL) {
887 return FALSE; 887 return FALSE;
888 } 888 }
889 FXSYS_memset32(dst_buf, 0, dst_size); 889 FXSYS_memset32(dst_buf, 0, dst_size);
890 bmp_ptr->file_header.bfOffBits = head_size; 890 bmp_ptr->file_header.bfOffBits = head_size;
891 if (bmp_ptr->pal_ptr && pal_size) { 891 if (bmp_ptr->pal_ptr && pal_size) {
892 FXSYS_memcpy32(&dst_buf[head_size], bmp_ptr->pal_ptr, pal_size); 892 FXSYS_memcpy32(&dst_buf[head_size], bmp_ptr->pal_ptr, pal_size);
893 bmp_ptr->file_header.bfOffBits += pal_size; 893 bmp_ptr->file_header.bfOffBits += pal_size;
894 } 894 }
895 WriteInfoHeader(&bmp_ptr->info_header, dst_buf); 895 WriteInfoHeader(&bmp_ptr->info_header, dst_buf);
(...skipping 12 matching lines...) Expand all
908 case BMP_RLE4: 908 case BMP_RLE4:
909 _bmp_encode_rle4(bmp_ptr, dst_buf, dst_size); 909 _bmp_encode_rle4(bmp_ptr, dst_buf, dst_size);
910 break; 910 break;
911 default: 911 default:
912 ; 912 ;
913 } 913 }
914 bmp_ptr->file_header.bfSize = dst_size; 914 bmp_ptr->file_header.bfSize = dst_size;
915 WriteFileHeader(&bmp_ptr->file_header, dst_buf); 915 WriteFileHeader(&bmp_ptr->file_header, dst_buf);
916 return TRUE; 916 return TRUE;
917 } 917 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/codec/fx_codec.cpp ('k') | core/src/fxcodec/lgif/fx_gif.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698