va{h264,h265,av1}enc: fix potential crash on devices without rate control

This fixes a crash in `gst_va_h264_enc_class_init` and `gst_va_h265_enc_class_init`
(and probably also in gst_va_av1_enc_class_init) when calling
`g_object_class_install_properties (object_class, n_props, properties);`

When rate_control_type is 0, the following code is executed in :

```
  } else {
    n_props--;
    properties[PROP_RATE_CONTROL] = NULL;
  }
```

n_props has initially a value of N_PROPERTIES but PROP_RATE_CONTROL
is not the last element in the array, so it's making
g_object_class_install_properties fail to iterate over the
properties array.

This applies the same fix to gstvah264enc.c, gstvah265enc.c and
gstvaav1enc.c.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6319>
This commit is contained in:
Antonio Larrosa 2024-03-11 12:42:48 +01:00 committed by GStreamer Marge Bot
parent bd97973ce0
commit 7b8fa42f8a
3 changed files with 3 additions and 3 deletions

View file

@ -86,11 +86,11 @@ enum
PROP_TARGET_PERCENTAGE, PROP_TARGET_PERCENTAGE,
PROP_TARGET_USAGE, PROP_TARGET_USAGE,
PROP_CPB_SIZE, PROP_CPB_SIZE,
PROP_RATE_CONTROL,
PROP_NUM_TILE_COLS, PROP_NUM_TILE_COLS,
PROP_NUM_TILE_ROWS, PROP_NUM_TILE_ROWS,
PROP_TILE_GROUPS, PROP_TILE_GROUPS,
PROP_MBBRC, PROP_MBBRC,
PROP_RATE_CONTROL,
N_PROPERTIES N_PROPERTIES
}; };

View file

@ -100,10 +100,10 @@ enum
PROP_BITRATE, PROP_BITRATE,
PROP_TARGET_PERCENTAGE, PROP_TARGET_PERCENTAGE,
PROP_TARGET_USAGE, PROP_TARGET_USAGE,
PROP_RATE_CONTROL,
PROP_CPB_SIZE, PROP_CPB_SIZE,
PROP_AUD, PROP_AUD,
PROP_CC, PROP_CC,
PROP_RATE_CONTROL,
N_PROPERTIES N_PROPERTIES
}; };

View file

@ -88,11 +88,11 @@ enum
PROP_BITRATE, PROP_BITRATE,
PROP_TARGET_PERCENTAGE, PROP_TARGET_PERCENTAGE,
PROP_TARGET_USAGE, PROP_TARGET_USAGE,
PROP_RATE_CONTROL,
PROP_CPB_SIZE, PROP_CPB_SIZE,
PROP_AUD, PROP_AUD,
PROP_NUM_TILE_COLS, PROP_NUM_TILE_COLS,
PROP_NUM_TILE_ROWS, PROP_NUM_TILE_ROWS,
PROP_RATE_CONTROL,
N_PROPERTIES N_PROPERTIES
}; };