Browse Source

engine: imagelib: bmp: fix unaligned access

pull/2/head
Alibek Omarov 6 years ago
parent
commit
6f2016db06
  1. 18
      engine/common/imagelib/img_bmp.c

18
engine/common/imagelib/img_bmp.c

@ -46,22 +46,8 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
if( filesize < sizeof( bhdr )) return false; if( filesize < sizeof( bhdr )) return false;
buf_p = (byte *)buffer; buf_p = (byte *)buffer;
bhdr.id[0] = *buf_p++; memcpy( &bhdr, buf_p, sizeof( bmp_t ));
bhdr.id[1] = *buf_p++; // move pointer buf_p += sizeof( bmp_t );
bhdr.fileSize = *(int *)buf_p; buf_p += 4;
bhdr.reserved0 = *(int *)buf_p; buf_p += 4;
bhdr.bitmapDataOffset = *(int *)buf_p; buf_p += 4;
bhdr.bitmapHeaderSize = *(int *)buf_p; buf_p += 4;
bhdr.width = *(int *)buf_p; buf_p += 4;
bhdr.height = *(int *)buf_p; buf_p += 4;
bhdr.planes = *(short *)buf_p; buf_p += 2;
bhdr.bitsPerPixel = *(short *)buf_p; buf_p += 2;
bhdr.compression = *(int *)buf_p; buf_p += 4;
bhdr.bitmapDataSize = *(int *)buf_p; buf_p += 4;
bhdr.hRes = *(int *)buf_p; buf_p += 4;
bhdr.vRes = *(int *)buf_p; buf_p += 4;
bhdr.colors = *(int *)buf_p; buf_p += 4;
bhdr.importantColors = *(int *)buf_p; buf_p += 4;
// bogus file header check // bogus file header check
if( bhdr.reserved0 != 0 ) return false; if( bhdr.reserved0 != 0 ) return false;

Loading…
Cancel
Save