Skip to content

Commit

Permalink
ras_enc: check components for RGB, fixes NULL pointer dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Jun 28, 2020
1 parent fc0397d commit 12db807
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/libjasper/ras/ras_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ static int ras_putdatastd(jas_stream_t *out, ras_hdr_t *hdr, jas_image_t *image,

assert(numcmpts <= 3);

if (RAS_ISRGB(hdr) && numcmpts < 3) {
/* need 3 components for RGB */
return -1;
}

for (i = 0; i < 3; ++i) {
data[i] = 0;
}
Expand Down

0 comments on commit 12db807

Please sign in to comment.