Mercurial > libavcodec.hg
comparison iff.c @ 11718:f2beca0bbf98 libavcodec
Handle palette underflows, fill remaining space with black (zero) data.
Patch by Sebastian Vater <cdgs basty googlemail com>.
| author | rbultje |
|---|---|
| date | Thu, 13 May 2010 15:33:36 +0000 |
| parents | 269ce565c70b |
| children | 30356abc8604 |
comparison
equal
deleted
inserted
replaced
| 11717:269ce565c70b | 11718:f2beca0bbf98 |
|---|---|
| 121 av_log(avctx, AV_LOG_ERROR, "bit_per_coded_sample > 8 not supported\n"); | 121 av_log(avctx, AV_LOG_ERROR, "bit_per_coded_sample > 8 not supported\n"); |
| 122 return AVERROR_INVALIDDATA; | 122 return AVERROR_INVALIDDATA; |
| 123 } | 123 } |
| 124 | 124 |
| 125 count = 1 << avctx->bits_per_coded_sample; | 125 count = 1 << avctx->bits_per_coded_sample; |
| 126 if (avctx->extradata_size < count * 3) { | 126 // If extradata is smaller than actually needed, fill the remaining with black. |
| 127 av_log(avctx, AV_LOG_ERROR, "palette data underflow\n"); | 127 count = FFMIN(avctx->extradata_size / 3, count); |
| 128 return AVERROR_INVALIDDATA; | |
| 129 } | |
| 130 for (i=0; i < count; i++) { | 128 for (i=0; i < count; i++) { |
| 131 pal[i] = 0xFF000000 | AV_RB24( avctx->extradata + i*3 ); | 129 pal[i] = 0xFF000000 | AV_RB24( avctx->extradata + i*3 ); |
| 132 } | 130 } |
| 133 return 0; | 131 return 0; |
| 134 } | 132 } |
