History

avfilter/vf_vif: Fix mismatch in number of array elements

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.

Andreas Rheinhardt committed 5 years ago

Commit 71eb8f81 parent 7dfdc151 file · +6 −4Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/vf_vif.c+6−4
@@ -38,6 +38,8 @@ · 37 unmodified lines
3838 #include "vif.h"
3939 #include "video.h"
4040
41+#define NUM_DATA_BUFS 13
42+
4143 typedef struct VIFContext {
4244 const AVClass *class;
4345 FFFrameSync fs;
@@ -46,7 +48,7 @@ typedef struct VIFContext { · 2 unmodified lines
4648 int height;
4749 int nb_threads;
4850 float factor;
49− float *data_buf[13];
51+ float *data_buf[NUM_DATA_BUFS];
5052 float **temp;
5153 float *ref_data;
5254 float *main_data;
@@ -286,7 +288,7 @@ static int vif_filter1d(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) · 233 unmodified lines
286288 int ff_compute_vif2(AVFilterContext *ctx,
287289 const float *ref, const float *main, int w, int h,
288290 int ref_stride, int main_stride, float *score,
289− float *data_buf[14], float **temp,
291+ float *data_buf[NUM_DATA_BUFS], float **temp,
290292 int gnb_threads)
291293 {
292294 ThreadData td;
@@ -515,7 +517,7 @@ static int config_input_ref(AVFilterLink *inlink) · 222 unmodified lines
515517 s->vif_max[i] = -DBL_MAX;
516518 }
517519
518− for (int i = 0; i < 13; i++) {
520+ for (int i = 0; i < NUM_DATA_BUFS; i++) {
519521 if (!(s->data_buf[i] = av_calloc(s->width, s->height * sizeof(float))))
520522 return AVERROR(ENOMEM);
521523 }
@@ -608,7 +610,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 86 unmodified lines
608610 i, s->vif_sum[i] / s->nb_frames, s->vif_min[i], s->vif_max[i]);
609611 }
610612
611− for (int i = 0; i < 13; i++)
613+ for (int i = 0; i < NUM_DATA_BUFS; i++)
612614 av_freep(&s->data_buf[i]);
613615
614616 av_freep(&s->ref_data);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t