Skip to content

Commit

Permalink
stdout can technically be null, so check it
Browse files Browse the repository at this point in the history
  • Loading branch information
brlcad committed Feb 1, 2025
1 parent d2fd3b9 commit 0876097
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/util/pixdiff.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ rgb_diff(int c1, int c2, FILE *output, size_t *offmany, size_t *off1, size_t *ma
{
int i;

if (!output)
if (!output) {
output = stdout;
}
if (!offmany || !off1 || !matching)
return;

Expand All @@ -58,14 +59,17 @@ rgb_diff(int c1, int c2, FILE *output, size_t *offmany, size_t *off1, size_t *ma
if (i < 0)
i = -i;
if (i > 1) {
fputc(0xFF, output);
if (output)
fputc(0xFF, output);
(*offmany)++;
} else {
fputc(0xC0, output);
if (output)
fputc(0xC0, output);
(*off1)++;
}
} else {
fputc(0, output);
if (output)
fputc(0, output);
(*matching)++;
}
}
Expand Down

0 comments on commit 0876097

Please sign in to comment.