The latter need not be save, because av_log() expects to get a pointer to an AVClass-enabled structure and not only a fake object. If this function were actually be called in the following way: const AVClass *avcl = avctx->av_class; handle_mdcv(&avcl, ); the AVClass's item_name would expect to point to an actual AVCodecContext, potentially leading to a segfault.
Unified · Split
| @@ -175,7 +175,7 @@ static av_cold int libx265_param_parse_int(AVCodecContext *avctx, · 174 unmodified lines | |||
| 175 | return 0; | 175 | return 0; |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | static int handle_mdcv(const AVClass **avcl, const x265_api *api, | 178 | static int handle_mdcv(void *logctx, const x265_api *api, |
| 179 | x265_param *params, | 179 | x265_param *params, |
| 180 | const AVMasteringDisplayMetadata *mdcv) | 180 | const AVMasteringDisplayMetadata *mdcv) |
| 181 | { | 181 | { |
| @@ -198,7 +198,7 @@ static int handle_mdcv(const AVClass **avcl, const x265_api *api, · 16 unmodified lines | |||
| 198 | 198 | ||
| 199 | if (api->param_parse(params, "master-display", buf) == | 199 | if (api->param_parse(params, "master-display", buf) == |
| 200 | X265_PARAM_BAD_VALUE) { | 200 | X265_PARAM_BAD_VALUE) { |
| 201 | av_log(avcl, AV_LOG_ERROR, | 201 | av_log(logctx, AV_LOG_ERROR, |
| 202 | "Invalid value \"%s\" for param \"master-display\".\n", | 202 | "Invalid value \"%s\" for param \"master-display\".\n", |
| 203 | buf); | 203 | buf); |
| 204 | return AVERROR(EINVAL); | 204 | return AVERROR(EINVAL); |
| @@ -230,7 +230,7 @@ static int handle_side_data(AVCodecContext *avctx, const x265_api *api, · 25 unmodified lines | |||
| 230 | 230 | ||
| 231 | if (mdcv_sd) { | 231 | if (mdcv_sd) { |
| 232 | int ret = handle_mdcv( | 232 | int ret = handle_mdcv( |
| 233 | &avctx->av_class, api, params, | 233 | avctx, api, params, |
| 234 | (AVMasteringDisplayMetadata *)mdcv_sd->data); | 234 | (AVMasteringDisplayMetadata *)mdcv_sd->data); |
| 235 | if (ret < 0) | 235 | if (ret < 0) |
| 236 | return ret; | 236 | return ret; |