changeset 12942:abe577c2b12e

Corrected my mistake in the last memfix patch. Bug was discovered by Shachar Raindel <shacharr@gmail.com>. The basic patch idea is also from him.
author al
date Tue, 03 Aug 2004 12:21:14 +0000
parents 876bcf984097
children a33eaabcac20
files input/input.c
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/input/input.c	Tue Aug 03 11:25:18 2004 +0000
+++ b/input/input.c	Tue Aug 03 12:21:14 2004 +0000
@@ -1484,15 +1484,24 @@
   if(!file)
     return;
   
-  if( mp_input_parse_config(file)) {
-    free(file); // release the buffer created by get_path()
-  }
-  else {
+  if( !mp_input_parse_config(file)) {
+    // free file if it was allocated by get_path(),
+    // before it gets overwritten
+    if( file != config_file)
+    {
+      free(file);
+    }
     // Try global conf dir
     file = MPLAYER_CONFDIR "/input.conf";
     if(! mp_input_parse_config(file))
       mp_msg(MSGT_INPUT,MSGL_WARN,"Falling back on default (hardcoded) input config\n");
   }
+  else
+  {
+    // free file if it was allocated by get_path()
+    if( file != config_file)
+      free(file);
+  }
 
 #ifdef HAVE_JOYSTICK
   if(use_joystick) {