On Tue May 7 08:37:34 2024 +0000, Rémi Bernon wrote:
I don't understand? This is used to iterate in an array of DEVMODEW, the allocated array might be larger than what is actually used but that doesn't matter? NEXT_DEVMODEW will be used to move to the next devmode in the array and fill it.
``` static void add_xrandr14_mode( DEVMODEW *mode, XRRModeInfo *info, DWORD depth, DWORD frequency, DWORD orientation ) DWORD orientation, BOOL full ) { mode->dmSize = sizeof(*mode); mode->dmDriverExtra = sizeof(RRMode); mode->dmDriverExtra = full ? sizeof(RRMode) : 0; ``` ``` /* Allocate space for display modes in different color depths and orientations. * Store a RRMode at the end of each DEVMODEW as private driver data */ modes = calloc( output_info->nmode * DEPTH_COUNT * orientation_count, sizeof(*modes) + sizeof(RRMode) ); ```
The problem is that dmDriverExtra is 0 when full is FALSE, yet the memory for dmDriverExtra is still allocated, which means you can't use NEXT_DEVMODEW to iterate such a DEVMODEW array.