Mercurial > mplayer.hg
changeset 36780:a5550a57a6cb
Fix bug with Win32 GUI preferences.
Determine string length in order to properly allocate memory.
author | ib |
---|---|
date | Mon, 17 Feb 2014 14:36:16 +0000 |
parents | f5320e43d458 |
children | e5c790cab2e8 |
files | gui/win32/preferences.c |
diffstat | 1 files changed, 14 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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);