]> granicus.if.org Git - libx264/commitdiff
Fix length of strings stored in the registry.
authorLoren Merritt <pengvado@videolan.org>
Tue, 25 Jan 2005 22:25:05 +0000 (22:25 +0000)
committerLoren Merritt <pengvado@videolan.org>
Tue, 25 Jan 2005 22:25:05 +0000 (22:25 +0000)
Patch by Riccardo Stievano.

git-svn-id: svn://svn.videolan.org/x264/trunk@107 df754926-b1dd-0310-bc7b-ec298dee348c

vfw/config.c

index 0e25d664a94ba2c4a970399e0287f339a9b1ea93..195351835a0881d3bbec52ae109ced6300f523bd 100644 (file)
@@ -61,6 +61,7 @@ typedef struct
     char *reg_value;
     char *config_str;
     char *default_str;
+    int max_len;  /* maximum string length, including the terminating NULL char */
 } reg_str_t;
 
 CONFIG reg;
@@ -100,8 +101,8 @@ static const reg_int_t reg_int_table[] =
 
 static const reg_str_t reg_str_table[] =
 {
-    { "fourcc",         reg.fcc,                "h264" },
-    { "statsfile",      reg.stats,              ".\\x264.stats" }
+    { "fourcc",         reg.fcc,         "h264",                5 },
+    { "statsfile",      reg.stats,       ".\\x264.stats",       MAX_PATH }
 };
 
 void config_reg_load( CONFIG *config )
@@ -126,7 +127,7 @@ void config_reg_load( CONFIG *config )
     /* Read strings */
     for( i = 0; i < sizeof( reg_str_table )/sizeof( reg_str_t); i++ )
     {
-        i_size = MAX_PATH;
+        i_size = reg_str_table[i].max_len;
         if( RegQueryValueEx( hKey, reg_str_table[i].reg_value, 0, 0,
                              (LPBYTE)reg_str_table[i].config_str,
                              &i_size ) != ERROR_SUCCESS )
@@ -168,7 +169,7 @@ void config_reg_save( CONFIG *config )
     {
         RegSetValueEx( hKey, reg_str_table[i].reg_value, 0, REG_SZ,
                        (LPBYTE)reg_str_table[i].config_str,
-                        MAX_PATH );
+                        lstrlen(reg_str_table[i].config_str)+1 );
     }
 
     RegCloseKey( hKey );