Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtschump committed Nov 27, 2023
2 parents 648a1bb + cb9c551 commit c56a0a1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions CImg.h
Original file line number Diff line number Diff line change
Expand Up @@ -56062,15 +56062,21 @@ namespace cimg_library {
bool endian = false;
unsigned int header_size;
cimg::fread(&header_size,1,nfile_header);
if (!header_size)
if (header_size>=4096) { endian = true; cimg::invert_endianness(header_size); }
if (header_size<128)
throw CImgIOException(_cimg_instance
"load_analyze(): Invalid zero-size header in file '%s'.",
"load_analyze(): Invalid header size (%u) specified in file '%s'.",
cimg_instance,
filename?filename:"(FILE*)");
if (header_size>=4096) { endian = true; cimg::invert_endianness(header_size); }
header_size,filename?filename:"(FILE*)");

unsigned char *const header = new unsigned char[header_size];
cimg::fread(header + 4,header_size - 4,nfile_header);
const size_t header_size_read = cimg::fread(header + 4,header_size - 4,nfile_header);
if (header_size_read!=header_size - 4)
throw CImgIOException(_cimg_instance
"load_analyze(): Cannot read header (of size %u) in file '%s'.",
cimg_instance,
header_size,filename?filename:"(FILE*)");

if (!file && nfile_header!=nfile) cimg::fclose(nfile_header);
if (endian) {
cimg::invert_endianness((short*)(header + 40),5);
Expand Down

0 comments on commit c56a0a1

Please sign in to comment.