comparison imgutils.c @ 26:ec642b5a1d0a libavcore

Add missing checks on invalid pixel format in av_image_fill_linesizes/pointers.
author stefano
date Tue, 07 Sep 2010 23:41:18 +0000
parents 63d8168fa16a
children
comparison
equal deleted inserted replaced
25:63d8168fa16a 26:ec642b5a1d0a
64 int max_step [4]; /* max pixel step for each plane */ 64 int max_step [4]; /* max pixel step for each plane */
65 int max_step_comp[4]; /* the component for each plane which has the max pixel step */ 65 int max_step_comp[4]; /* the component for each plane which has the max pixel step */
66 66
67 memset(linesizes, 0, 4*sizeof(linesizes[0])); 67 memset(linesizes, 0, 4*sizeof(linesizes[0]));
68 68
69 if (desc->flags & PIX_FMT_HWACCEL) 69 if ((unsigned)pix_fmt >= PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL)
70 return AVERROR(EINVAL); 70 return AVERROR(EINVAL);
71 71
72 if (desc->flags & PIX_FMT_BITSTREAM) { 72 if (desc->flags & PIX_FMT_BITSTREAM) {
73 linesizes[0] = (width * (desc->comp[0].step_minus1+1) + 7) >> 3; 73 linesizes[0] = (width * (desc->comp[0].step_minus1+1) + 7) >> 3;
74 return 0; 74 return 0;
91 const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; 91 const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
92 memset(data , 0, sizeof(data[0])*4); 92 memset(data , 0, sizeof(data[0])*4);
93 memset(size , 0, sizeof(size)); 93 memset(size , 0, sizeof(size));
94 memset(has_plane, 0, sizeof(has_plane)); 94 memset(has_plane, 0, sizeof(has_plane));
95 95
96 if (desc->flags & PIX_FMT_HWACCEL) 96 if ((unsigned)pix_fmt >= PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL)
97 return AVERROR(EINVAL); 97 return AVERROR(EINVAL);
98 98
99 data[0] = ptr; 99 data[0] = ptr;
100 size[0] = linesizes[0] * height; 100 size[0] = linesizes[0] * height;
101 101