@@ -490,7 +490,7 @@ static AVBufferRef *vaapi_pool_alloc(void *opaque, size_t size)
av_log(hwfc, AV_LOG_DEBUG, "Created surface %#x.\n", surface_id);
ref = av_buffer_create((uint8_t*)(uintptr_t)surface_id,
- sizeof(surface_id), &vaapi_buffer_free,
+ 0, &vaapi_buffer_free,
hwfc, AV_BUFFER_FLAG_READONLY);
if (!ref) {
vaDestroySurfaces(hwctx->display, &surface_id, 1);
@@ -593,7 +593,7 @@ static int vaapi_frames_init(AVHWFramesContext *hwfc)
}
hwfc->internal->pool_internal =
- av_buffer_pool_init2(sizeof(VASurfaceID), hwfc,
+ av_buffer_pool_init2(0, hwfc,
&vaapi_pool_alloc, NULL);
if (!hwfc->internal->pool_internal) {
av_log(hwfc, AV_LOG_ERROR, "Failed to create VAAPI surface pool.\n");
In this case there is no underlying data at all; the actual data has been shoe-horned into the pointer, which does not point to any storage owned by us. So use a size of zero as buffer pool size. (This fixes segfaults if one uses vaapi with memory poisoning enabled; but the memset call in pool_release_buffer() still receives an invalid pointer, so it is still undefined behaviour.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavutil/hwcontext_vaapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)