# HG changeset patch # User ib # Date 1393252348 0 # Node ID b2e529a2cbab8d1ae719ca6f253a8a6eb658d3e0 # Parent 5691f930dca657e07de505eddbaa5e84e8696b59 Fix bug with Win32 GUI preferences. Determine string length in order to properly allocate memory. diff -r 5691f930dca6 -r b2e529a2cbab gui/win32/preferences.c --- 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)