]> granicus.if.org Git - php/commitdiff
Fix resetting of internal_encoding and friends
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 17 Dec 2019 15:26:42 +0000 (16:26 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 17 Dec 2019 15:27:56 +0000 (16:27 +0100)
We need to update the value even if new_value is NULL. In particular,
it should be reset back to NULL after each request if the setting was
not specified on startup. Otherwise we leave dangling pointers.

main/main.c

index 5c81ea046d7a797a0f8bcde1c920b5df49a2974b..7890b2ebeb12fff0e9c7fb6ddc456d7baf62a463 100644 (file)
@@ -594,11 +594,11 @@ PHPAPI void (*php_internal_encoding_changed)(void) = NULL;
  */
 static PHP_INI_MH(OnUpdateDefaultCharset)
 {
+       OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
+       if (php_internal_encoding_changed) {
+               php_internal_encoding_changed();
+       }
        if (new_value) {
-               OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
-               if (php_internal_encoding_changed) {
-                       php_internal_encoding_changed();
-               }
 #ifdef PHP_WIN32
                php_win32_cp_do_update(ZSTR_VAL(new_value));
 #endif
@@ -611,11 +611,11 @@ static PHP_INI_MH(OnUpdateDefaultCharset)
  */
 static PHP_INI_MH(OnUpdateInternalEncoding)
 {
+       OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
+       if (php_internal_encoding_changed) {
+               php_internal_encoding_changed();
+       }
        if (new_value) {
-               OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
-               if (php_internal_encoding_changed) {
-                       php_internal_encoding_changed();
-               }
 #ifdef PHP_WIN32
                php_win32_cp_do_update(ZSTR_VAL(new_value));
 #endif
@@ -628,11 +628,11 @@ static PHP_INI_MH(OnUpdateInternalEncoding)
  */
 static PHP_INI_MH(OnUpdateInputEncoding)
 {
+       OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
+       if (php_internal_encoding_changed) {
+               php_internal_encoding_changed();
+       }
        if (new_value) {
-               OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
-               if (php_internal_encoding_changed) {
-                       php_internal_encoding_changed();
-               }
 #ifdef PHP_WIN32
                php_win32_cp_do_update(NULL);
 #endif
@@ -645,11 +645,11 @@ static PHP_INI_MH(OnUpdateInputEncoding)
  */
 static PHP_INI_MH(OnUpdateOutputEncoding)
 {
+       OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
+       if (php_internal_encoding_changed) {
+               php_internal_encoding_changed();
+       }
        if (new_value) {
-               OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
-               if (php_internal_encoding_changed) {
-                       php_internal_encoding_changed();
-               }
 #ifdef PHP_WIN32
                php_win32_cp_do_update(NULL);
 #endif