Skip to content

Commit

Permalink
ensure code will compile with an ANSI-C compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristy committed Jan 28, 2023
1 parent 25d201d commit 2c240b7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions coders/heic.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,26 @@ static MagickBooleanType ReadHEICExifProfile(Image *image,
/*
Extract Exif profile.
*/
size_t exif_length = GetStringInfoLength(exif_profile);
unsigned char *exif_datum = GetStringInfoDatum(exif_profile);
StringInfo *snippet = SplitStringInfo(exif_profile,4);
unsigned int offset = 0;
offset|=(unsigned int) (*(GetStringInfoDatum(snippet)+0)) << 24;
offset|=(unsigned int) (*(GetStringInfoDatum(snippet)+1)) << 16;
offset|=(unsigned int) (*(GetStringInfoDatum(snippet)+2)) << 8;
offset|=(unsigned int) (*(GetStringInfoDatum(snippet)+3)) << 0;
snippet=DestroyStringInfo(snippet);
/*
Strip any EOI marker if payload starts with a JPEG marker.
*/
if ((exif_length > 2) &&
((memcmp(exif_datum,"\0xFF\0xD8",2) == 0) ||
(memcmp(exif_datum,"\0xFF\0xE1",2) == 0)) &&
memcmp(exif_datum+exif_length-2,"\0xFF\0xD9",2) == 0)
SetStringInfoLength(exif_profile,exif_length-2);
/*
Skip to actual Exif payload.
*/
if (offset < GetStringInfoLength(exif_profile))
{
(void) DestroyStringInfo(SplitStringInfo(exif_profile,offset));
Expand Down

0 comments on commit 2c240b7

Please sign in to comment.