changeset 36834:b2e529a2cbab

Fix bug with Win32 GUI preferences. Determine string length in order to properly allocate memory.
author ib
date Mon, 24 Feb 2014 14:32:28 +0000
parents 5691f930dca6
children 6bc38224c74a
files gui/win32/preferences.c
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/gui/win32/preferences.c	Mon Feb 24 14:25:53 2014 +0000
+++ b/gui/win32/preferences.c	Mon Feb 24 14:32:28 2014 +0000
@@ -46,7 +46,6 @@
     HWND btn, label, edit1, edit2, updown1, updown2, track1, track2;
     static HWND vo_driver, ao_driver, prio;
     int i = 0, j = 0;
-    char procprio[11];
     float stereopos = gtkAOExtraStereoMul * 10.0;
     float delaypos = audio_delay * 10.0;
 
@@ -520,7 +519,7 @@
                 case ID_APPLY:
                 {
                     int idx, strl;
-                    char *driver, *caption;
+                    char *driver, *procprio, *caption;
 
                     /* Set the video driver */
                     idx = SendMessage(vo_driver, CB_GETCURSEL, 0, 0);
@@ -539,8 +538,12 @@
                     free(driver);
 
                     /* Set the priority level */
-                    SendMessage(prio, CB_GETLBTEXT, (WPARAM)SendMessage(prio, CB_GETCURSEL, 0, 0), (LPARAM)procprio);
+                    idx = SendMessage(prio, CB_GETCURSEL, 0, 0);
+                    strl = SendMessage(prio, CB_GETLBTEXTLEN, (WPARAM)idx, 0);
+                    procprio = malloc(strl + 1);
+                    SendMessage(prio, CB_GETLBTEXT, (WPARAM)idx, (LPARAM)procprio);
                     setdup(&proc_priority, procprio);
+                    free(procprio);
 
                     /* double buffering */
                     if(SendDlgItemMessage(hwnd, ID_DOUBLE, BM_GETCHECK, 0, 0) == BST_CHECKED)