The function definition used float *data_buf[14], although there are only 13 elements (and only 13 are used); the declaration used 13. Given that the type will be converted to float **data_buf anyway, this is not in violation of the C specs, but nevertheless a bug. GCC 11 has a new warning for this -Warray-parameter.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -38,6 +38,8 @@ · 37 unmodified lines | ||
| 38 | 38 | #include "vif.h" |
| 39 | 39 | #include "video.h" |
| 40 | 40 | |
| 41 | +#define NUM_DATA_BUFS 13 | |
| 42 | + | |
| 41 | 43 | typedef struct VIFContext { |
| 42 | 44 | const AVClass *class; |
| 43 | 45 | FFFrameSync fs; |
| @@ -46,7 +48,7 @@ typedef struct VIFContext { · 2 unmodified lines | ||
| 46 | 48 | int height; |
| 47 | 49 | int nb_threads; |
| 48 | 50 | float factor; |
| 49 | − float *data_buf[13]; | |
| 51 | + float *data_buf[NUM_DATA_BUFS]; | |
| 50 | 52 | float **temp; |
| 51 | 53 | float *ref_data; |
| 52 | 54 | float *main_data; |
| @@ -286,7 +288,7 @@ static int vif_filter1d(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) · 233 unmodified lines | ||
| 286 | 288 | int ff_compute_vif2(AVFilterContext *ctx, |
| 287 | 289 | const float *ref, const float *main, int w, int h, |
| 288 | 290 | int ref_stride, int main_stride, float *score, |
| 289 | − float *data_buf[14], float **temp, | |
| 291 | + float *data_buf[NUM_DATA_BUFS], float **temp, | |
| 290 | 292 | int gnb_threads) |
| 291 | 293 | { |
| 292 | 294 | ThreadData td; |
| @@ -515,7 +517,7 @@ static int config_input_ref(AVFilterLink *inlink) · 222 unmodified lines | ||
| 515 | 517 | s->vif_max[i] = -DBL_MAX; |
| 516 | 518 | } |
| 517 | 519 | |
| 518 | − for (int i = 0; i < 13; i++) { | |
| 520 | + for (int i = 0; i < NUM_DATA_BUFS; i++) { | |
| 519 | 521 | if (!(s->data_buf[i] = av_calloc(s->width, s->height * sizeof(float)))) |
| 520 | 522 | return AVERROR(ENOMEM); |
| 521 | 523 | } |
| @@ -608,7 +610,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 86 unmodified lines | ||
| 608 | 610 | i, s->vif_sum[i] / s->nb_frames, s->vif_min[i], s->vif_max[i]); |
| 609 | 611 | } |
| 610 | 612 | |
| 611 | − for (int i = 0; i < 13; i++) | |
| 613 | + for (int i = 0; i < NUM_DATA_BUFS; i++) | |
| 612 | 614 | av_freep(&s->data_buf[i]); |
| 613 | 615 | |
| 614 | 616 | av_freep(&s->ref_data); |