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

Conversation

wantehchang
Copy link
Collaborator

In avifDecoderGenerateImageGridTiles(), replace unprintable characters in item->type with '.' and also print the hex values of item->type in parentheses.

For example, if item->type is four NUL characters ('\0'), avifdec prints the following diagnostic message:

Before:
Diagnostics:

  • Tile item ID 5 has an unknown item type ''

After:
Diagnostics:

  • Tile item ID 5 has an unknown item type '....' (0000 0000)

In avifDecoderGenerateImageGridTiles(), replace unprintable characters
in item->type with '.' and also print the hex values of item->type in
parentheses.

For example, if item->type is four NUL characters ('\0'), avifdec prints
the following diagnostic message:

Before:
  Diagnostics:
   * Tile item ID 5 has an unknown item type ''

After:
  Diagnostics:
   * Tile item ID 5 has an unknown item type '....' (0000 0000)
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.

src/read.c Outdated Show resolved Hide resolved
@wantehchang wantehchang merged commit 695c2d1 into AOMediaCodec:main Feb 13, 2024
20 checks passed
@wantehchang wantehchang deleted the print-unprintable-item-type branch February 13, 2024 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants