You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.3 KiB

  1. commit 3763c8f1645983b5abc37c60597e1ecc1bf89019
  2. Author: Philip Prindeville <philipp@redfish-solutions.com>
  3. Date: Thu Jan 25 14:18:00 2018 -0700
  4. Always free out_buf in php_iconv_string()
  5. diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
  6. index 4289242..807bb14 100644
  7. --- a/ext/iconv/iconv.c
  8. +++ b/ext/iconv/iconv.c
  9. @@ -699,6 +699,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
  10. iconv_close(cd);
  11. if (result == (size_t)(-1)) {
  12. + zend_string_free(out_buf);
  13. switch (errno) {
  14. case EINVAL:
  15. retval = PHP_ICONV_ERR_ILLEGAL_CHAR;
  16. @@ -715,7 +716,6 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
  17. default:
  18. /* other error */
  19. - zend_string_free(out_buf);
  20. return PHP_ICONV_ERR_UNKNOWN;
  21. }
  22. }
  23. @@ -988,9 +988,6 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval,
  24. err = php_iconv_string(ndl, ndl_nbytes, &ndl_buf, GENERIC_SUPERSET_NAME, enc);
  25. if (err != PHP_ICONV_ERR_SUCCESS) {
  26. - if (ndl_buf != NULL) {
  27. - zend_string_free(ndl_buf);
  28. - }
  29. return err;
  30. }
  31. @@ -2494,9 +2491,6 @@ PHP_NAMED_FUNCTION(php_if_iconv)
  32. if (err == PHP_ICONV_ERR_SUCCESS && out_buffer != NULL) {
  33. RETVAL_STR(out_buffer);
  34. } else {
  35. - if (out_buffer != NULL) {
  36. - zend_string_free(out_buffer);
  37. - }
  38. RETURN_FALSE;
  39. }
  40. }