]> granicus.if.org Git - php/commitdiff
MFH
authorAntony Dovgal <tony2001@php.net>
Tue, 16 Jan 2007 11:19:10 +0000 (11:19 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 16 Jan 2007 11:19:10 +0000 (11:19 +0000)
ext/pspell/pspell.c

index 75b2aaac6e0539a49876c13e2b3c5ac41ba36e11..478d6ad9e5de0ec73e8d7f8bb8e01b7a64165c4e 100644 (file)
@@ -186,6 +186,7 @@ static PHP_FUNCTION(pspell_new)
         * 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 @@ static PHP_FUNCTION(pspell_new)
 
        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 @@ static PHP_FUNCTION(pspell_new_personal)
         * 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,10 +307,12 @@ static PHP_FUNCTION(pspell_new_personal)
        convert_to_string_ex(personal);
 
        if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(personal), NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
+               delete_pspell_config(config);
                RETURN_FALSE;
        }
 
        if (php_check_open_basedir(Z_STRVAL_PP(personal) TSRMLS_CC)) {
+               delete_pspell_config(config);
                RETURN_FALSE;
        }
 
@@ -363,6 +368,7 @@ static PHP_FUNCTION(pspell_new_personal)
 
        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;
        }
        
@@ -396,6 +402,7 @@ static PHP_FUNCTION(pspell_new_config)
 
        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;
        }
        
@@ -641,17 +648,18 @@ static PHP_FUNCTION(pspell_config_create)
     /* 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);