changeset 19948:92b4bcd07f0e

Avoid buffer overflow: memory has do be allocated accordingly when overwriting a string!
author reimar
date Sat, 23 Sep 2006 14:36:25 +0000
parents f53f1a780a54
children bf6bdb785567
files Gui/win32/preferences.c
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Gui/win32/preferences.c	Sat Sep 23 14:34:32 2006 +0000
+++ b/Gui/win32/preferences.c	Sat Sep 23 14:36:25 2006 +0000
@@ -562,14 +562,21 @@
                     return 0;
                 case ID_APPLY:
                 {
+                    int strl;
                     if(guiIntfStruct.Playing) guiGetEvent(guiCEvent, (void *)guiSetStop);
 
                     /* Set the video driver */
-                    SendMessage(vo_driver, CB_GETLBTEXT, (WPARAM)SendMessage(vo_driver, CB_GETCURSEL, 0, 0),
+                    gfree(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]);
 
                     /* Set the audio driver */
-                    SendMessage(ao_driver, CB_GETLBTEXT, (WPARAM)SendMessage(ao_driver, CB_GETCURSEL, 0, 0),
+                    gfree(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]);
 
                     /* Set the priority level */