# HG changeset patch # User ib # Date 1392647776 0 # Node ID a5550a57a6cb8ee129d50ac42b4a0c9edd0571d5 # Parent f5320e43d45832cc4e5443603297f6321af426b5 Fix bug with Win32 GUI preferences. Determine string length in order to properly allocate memory. diff -r f5320e43d458 -r a5550a57a6cb gui/win32/preferences.c --- a/gui/win32/preferences.c Mon Feb 17 14:33:03 2014 +0000 +++ b/gui/win32/preferences.c Mon Feb 17 14:36:16 2014 +0000 @@ -542,22 +542,24 @@ return 0; case ID_APPLY: { - int strl; - char *caption; + int idx, strl; + char *driver, *caption; /* Set the video driver */ - free(video_driver_list[0]); - strl = SendMessage(vo_driver, CB_GETCURSEL, 0, 0); - video_driver_list[0] = malloc(strl); - SendMessage(vo_driver, CB_GETLBTEXT, (WPARAM)strl, - (LPARAM)video_driver_list[0]); + idx = SendMessage(vo_driver, CB_GETCURSEL, 0, 0); + strl = SendMessage(vo_driver, CB_GETLBTEXTLEN, (WPARAM)idx, 0); + driver = malloc(strl + 1); + SendMessage(vo_driver, CB_GETLBTEXT, (WPARAM)idx, (LPARAM)driver); + listSet(&video_driver_list, driver); + free(driver); /* Set the audio driver */ - free(audio_driver_list[0]); - strl = SendMessage(ao_driver, CB_GETCURSEL, 0, 0); - audio_driver_list[0] = malloc(strl); - SendMessage(ao_driver, CB_GETLBTEXT, (WPARAM)strl, - (LPARAM)audio_driver_list[0]); + idx = SendMessage(ao_driver, CB_GETCURSEL, 0, 0); + strl = SendMessage(ao_driver, CB_GETLBTEXTLEN, (WPARAM)idx, 0); + driver = malloc(strl + 1); + SendMessage(ao_driver, CB_GETLBTEXT, (WPARAM)idx, (LPARAM)driver); + listSet(&audio_driver_list, driver); + free(driver); /* Set the priority level */ SendMessage(prio, CB_GETLBTEXT, (WPARAM)SendMessage(prio, CB_GETCURSEL, 0, 0), (LPARAM)procprio);