fix a double free caused by amdgpu_dri3_get_formats()

The function now allocates memory with malloc() and copies the formats array, instead of returning a pointer to static memory that the xserver would try to free() later.
This commit is contained in:
Joseph Crowell
2026-02-16 17:41:42 +10:00
parent 3f2da8f9b7
commit 3f48bbfe95
3 changed files with 10 additions and 5 deletions

View File

@@ -23,7 +23,7 @@
# Initialize Autoconf
AC_PREREQ([2.60])
AC_INIT([xlibre-xf86-video-amdgpu],
[25.1.0],
[25.1.1],
[https://github.com/X11Libre/xf86-video-amdgpu/issues],
[xlibre-xf86-video-amdgpu])

View File

@@ -1,7 +1,7 @@
project(
'xf86-video-amdgpu',
'c',
version: '25.1.0',
version: '25.1.1',
license: 'MIT',
meson_version: '>=0.59.0',
default_options: ['warning_level=1']

View File

@@ -829,10 +829,15 @@ amdgpu_dri3_get_formats(ScreenPtr screen, unsigned int *num_formats,
DRM_FORMAT_RGB332,
DRM_FORMAT_BGR233,
};
unsigned int count = sizeof(formats_arr) / sizeof(formats_arr[0]);
*num_formats = sizeof(formats_arr) / sizeof(formats_arr[0]);
*formats = (unsigned int *)formats_arr;
return sizeof(formats_arr) / sizeof(formats_arr[0]);
*formats = malloc(count * sizeof(uint32_t));
if (!*formats)
return 0;
memcpy(*formats, formats_arr, count * sizeof(uint32_t));
*num_formats = count;
return count;
}
/*