History

avcodec/libx265: Pass logctx as void*, not AVClass**

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.

Andreas Rheinhardt committed 2 years ago

Commit b9fcc131 parent 244db711 file · +3 −3Browse files

Unified · Split

libavcodec/libx265.c+3−3
@@ -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
178static int handle_mdcv(const AVClass **avcl, const x265_api *api,178static 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;

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