vo: hwdec: fix drmGetDeviceNameFromFd2() related memory leak

This commit fixes a minor memory leak related to drmGetDeviceNameFromFd2().
This function returns a string allocated with strdup().
This commit is contained in:
repojohnray 2023-01-03 01:14:01 +01:00 committed by Philip Langdale
parent 2e9c43f931
commit fee6847aa7
1 changed files with 5 additions and 1 deletions

View File

@ -299,10 +299,14 @@ static int init(struct ra_hwdec *hw)
.driver_name = hw->driver->name,
.hw_imgfmt = IMGFMT_DRMPRIME,
};
char *device = drmGetDeviceNameFromFd2(p->ctx->fd);
if (!av_hwdevice_ctx_create(&p->hwctx.av_device_ref, AV_HWDEVICE_TYPE_DRM,
drmGetDeviceNameFromFd2(p->ctx->fd), NULL, 0)) {
device, NULL, 0)) {
hwdec_devices_add(hw->devs, &p->hwctx);
}
if (device)
free(device);
return 0;