Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print unprintable item->type in diagnostic message #2000

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "avif/internal.h"

#include <assert.h>
#include <ctype.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
Expand Down Expand Up @@ -1421,7 +1422,22 @@ static avifResult avifDecoderGenerateImageGridTiles(avifDecoder * decoder, avifI
// as errors.
const avifCodecType tileCodecType = avifGetCodecType(item->type);
if (tileCodecType == AVIF_CODEC_TYPE_UNKNOWN) {
avifDiagnosticsPrintf(&decoder->diag, "Tile item ID %u has an unknown item type '%.4s'", item->id, (const char *)item->type);
char type[4];
for (int j = 0; j < 4; j++) {
if (isprint((unsigned char)item->type[j])) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The input argument to isprint() needs to be cast to unsigned char.

type[j] = item->type[j];
} else {
type[j] = '.';
}
}
avifDiagnosticsPrintf(&decoder->diag,
"Tile item ID %u has an unknown item type '%.4s' (%02x%02x%02x%02x)",
item->id,
type,
item->type[0],
item->type[1],
item->type[2],
item->type[3]);
return AVIF_RESULT_INVALID_IMAGE_GRID;
}

Expand Down
Loading