]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.1' into PHP-7.2
authorChristoph M. Becker <cmbecker69@gmx.de>
Sat, 4 Aug 2018 10:57:05 +0000 (12:57 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Sat, 4 Aug 2018 10:57:05 +0000 (12:57 +0200)
* PHP-7.1:
  Fix #76704: mb_detect_order return value varies based on argument type

1  2 
NEWS
ext/mbstring/mbstring.c

diff --cc NEWS
index 099b176b0fb5bfdbf62dac5ce34d3854b4191cd6,e02ef741311e4a73b6c240fc972034201c319fd3..379e1a97eeba8fd8fa5c50170ad6848a4e6de823
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -1,9 -1,12 +1,12 @@@
  PHP                                                                        NEWS
  |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 -?? ??? ????, PHP 7.1.22
 +?? ??? 2018, PHP 7.2.10
  
+ - mbstring:
+   . Fixed bug #76704 (mb_detect_order return value varies based on argument
+     type). (cmb)
  
 -16 Aug 2018, PHP 7.1.21
 +16 Aug 2018, PHP 7.2.9
  
  - Calendar:
    . Fixed bug #52974 (jewish.c: compile error under Windows with GBK charset).
index 3a9e51781a11a3db7d80a0be3081ba91b473964a,fa2d794e1a0f8a843a50e38cd9ed2360dae5b7d0..2ec7f1a3a8dce60a6867f97f39495498521789d3
@@@ -742,64 -724,74 +742,64 @@@ php_mb_parse_encoding_list(const char *
                size = n + MBSTRG(default_detect_order_list_size);
                /* make list */
                list = (const mbfl_encoding **)pecalloc(size, sizeof(mbfl_encoding*), persistent);
 -              if (list != NULL) {
 -                      entry = list;
 -                      n = 0;
 -                      bauto = 0;
 -                      p1 = tmpstr;
 -                      do {
 -                              p2 = p = (char*)php_memnstr(p1, ",", 1, endp);
 -                              if (p == NULL) {
 -                                      p = endp;
 -                              }
 +              entry = list;
 +              n = 0;
 +              bauto = 0;
 +              p1 = tmpstr;
 +              do {
 +                      p2 = p = (char*)php_memnstr(p1, ",", 1, endp);
 +                      if (p == NULL) {
 +                              p = endp;
 +                      }
 +                      *p = '\0';
 +                      /* trim spaces */
 +                      while (p1 < p && (*p1 == ' ' || *p1 == '\t')) {
 +                              p1++;
 +                      }
 +                      p--;
 +                      while (p > p1 && (*p == ' ' || *p == '\t')) {
                                *p = '\0';
 -                              /* trim spaces */
 -                              while (p1 < p && (*p1 == ' ' || *p1 == '\t')) {
 -                                      p1++;
 -                              }
                                p--;
 -                              while (p > p1 && (*p == ' ' || *p == '\t')) {
 -                                      *p = '\0';
 -                                      p--;
 -                              }
 -                              /* convert to the encoding number and check encoding */
 -                              if (strcasecmp(p1, "auto") == 0) {
 -                                      if (!bauto) {
 -                                              const enum mbfl_no_encoding *src = MBSTRG(default_detect_order_list);
 -                                              const size_t identify_list_size = MBSTRG(default_detect_order_list_size);
 -                                              size_t i;
 -                                              bauto = 1;
 -                                              for (i = 0; i < identify_list_size; i++) {
 -                                                      *entry++ = mbfl_no2encoding(*src++);
 -                                                      n++;
 -                                              }
 -                                      }
 -                              } else {
 -                                      const mbfl_encoding *encoding = mbfl_name2encoding(p1);
 -                                      if (encoding) {
 -                                              *entry++ = encoding;
 +                      }
 +                      /* convert to the encoding number and check encoding */
 +                      if (strcasecmp(p1, "auto") == 0) {
 +                              if (!bauto) {
 +                                      const enum mbfl_no_encoding *src = MBSTRG(default_detect_order_list);
 +                                      const size_t identify_list_size = MBSTRG(default_detect_order_list_size);
 +                                      size_t i;
 +                                      bauto = 1;
 +                                      for (i = 0; i < identify_list_size; i++) {
 +                                              *entry++ = mbfl_no2encoding(*src++);
                                                n++;
 -                                      } else {
 -                                              ret = FAILURE;
                                        }
                                }
 -                              p1 = p2 + 1;
 -                      } while (n < size && p2 != NULL);
 -                      if (n > 0) {
 -                              if (return_list) {
 -                                      *return_list = list;
 +                      } else {
 +                              const mbfl_encoding *encoding = mbfl_name2encoding(p1);
 +                              if (encoding) {
 +                                      *entry++ = encoding;
 +                                      n++;
                                } else {
-                                       ret = 0;
 -                                      pefree(list, persistent);
++                                      ret = FAILURE;
                                }
 +                      }
 +                      p1 = p2 + 1;
 +              } while (n < size && p2 != NULL);
 +              if (n > 0) {
 +                      if (return_list) {
 +                              *return_list = list;
                        } else {
                                pefree(list, persistent);
 -                              if (return_list) {
 -                                      *return_list = NULL;
 -                              }
 -                              ret = FAILURE;
 -                      }
 -                      if (return_size) {
 -                              *return_size = n;
                        }
                } else {
 +                      pefree(list, persistent);
                        if (return_list) {
                                *return_list = NULL;
                        }
-                       ret = 0;
 -                      if (return_size) {
 -                              *return_size = 0;
 -                      }
+                       ret = FAILURE;
                }
 +              if (return_size) {
 +                      *return_size = n;
 +              }
                efree(tmpstr);
        }