tony2001                Tue Jan 16 11:18:54 2007 UTC

  Modified files:              
    /php-src/ext/pspell pspell.c 
  Log:
  plug leaks
  initialize the last argument of RegQueryValueEx()
  fix ws
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pspell/pspell.c?r1=1.55&r2=1.56&diff_format=u
Index: php-src/ext/pspell/pspell.c
diff -u php-src/ext/pspell/pspell.c:1.55 php-src/ext/pspell/pspell.c:1.56
--- php-src/ext/pspell/pspell.c:1.55    Mon Jan  1 09:29:28 2007
+++ php-src/ext/pspell/pspell.c Tue Jan 16 11:18:54 2007
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: pspell.c,v 1.55 2007/01/01 09:29:28 sebastian Exp $ */
+/* $Id: pspell.c,v 1.56 2007/01/16 11:18:54 tony2001 Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -186,6 +186,7 @@
         * pointing to the location of the dictionaries
         */
        if(0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) {
+               dwLen = sizeof(aspell_dir) - 1;
                RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir, 
&dwLen);
                RegCloseKey(hkey);
                strcpy(data_dir, aspell_dir);
@@ -247,6 +248,7 @@
 
        if(pspell_error_number(ret) != 0){
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "PSPELL couldn't 
open the dictionary. reason: %s", pspell_error_message(ret));
+               delete_pspell_manager(ret);
                RETURN_FALSE;
        }
        
@@ -289,6 +291,7 @@
         * pointing to the location of the dictionaries
         */
        if(0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) {
+               dwLen = sizeof(aspell_dir) - 1;
                RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir, 
&dwLen);
                RegCloseKey(hkey);
                strcpy(data_dir, aspell_dir);
@@ -304,6 +307,7 @@
        convert_to_string_ex(personal);
 
        if (php_check_open_basedir(Z_STRVAL_PP(personal) TSRMLS_CC)) {
+               delete_pspell_config(config);
                RETURN_FALSE;
        }
 
@@ -359,6 +363,7 @@
 
        if(pspell_error_number(ret) != 0){
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "PSPELL couldn't 
open the dictionary. reason: %s", pspell_error_message(ret));
+               delete_pspell_manager(ret);
                RETURN_FALSE;
        }
        
@@ -392,6 +397,7 @@
 
        if(pspell_error_number(ret) != 0){
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "PSPELL couldn't 
open the dictionary. reason: %s", pspell_error_message(ret));
+               delete_pspell_manager(ret);
                RETURN_FALSE;
        }
        
@@ -637,17 +643,18 @@
     /* If aspell was installed using installer, we should have a key
      * pointing to the location of the dictionaries
      */
-    if(0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) {
-       RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir, &dwLen);
-       RegCloseKey(hkey);
-       strcpy(data_dir, aspell_dir);
-       strcat(data_dir, "\\data");
-       strcpy(dict_dir, aspell_dir);
-       strcat(dict_dir, "\\dict");
-
-       pspell_config_replace(config, "data-dir", data_dir);
-       pspell_config_replace(config, "dict-dir", dict_dir);
-      }
+       if(0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) {
+               dwLen = sizeof(aspell_dir) - 1;
+               RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir, 
&dwLen);
+               RegCloseKey(hkey);
+               strcpy(data_dir, aspell_dir);
+               strcat(data_dir, "\\data");
+               strcpy(dict_dir, aspell_dir);
+               strcat(dict_dir, "\\dict");
+
+               pspell_config_replace(config, "data-dir", data_dir);
+               pspell_config_replace(config, "dict-dir", dict_dir);
+       }
 #endif
 
        convert_to_string_ex(language);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to