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.

69 lines
2.0 KiB

  1. commit 31e53f07c26e5ac75ec2c2d99497439323dbdaf7
  2. Author: Philip Prindeville <philipp@redfish-solutions.com>
  3. Date: Wed Jan 24 18:47:19 2018 -0700
  4. Be consistent in clearing out in php_iconv_string()
  5. Also, don't bother checking returned point in error case since it
  6. will always be NULL (and not require free()ing, obviously).
  7. diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
  8. index 35dafd4..4289242 100644
  9. --- a/ext/iconv/iconv.c
  10. +++ b/ext/iconv/iconv.c
  11. @@ -559,6 +559,8 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
  12. size_t result;
  13. zend_string *ret, *out_buffer;
  14. + *out = NULL;
  15. +
  16. /*
  17. This is not the right way to get output size...
  18. This is not space efficient for large text.
  19. commit 3763c8f1645983b5abc37c60597e1ecc1bf89019
  20. Author: Philip Prindeville <philipp@redfish-solutions.com>
  21. Date: Thu Jan 25 14:18:00 2018 -0700
  22. Always free out_buf in php_iconv_string()
  23. diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
  24. index 4289242..807bb14 100644
  25. --- a/ext/iconv/iconv.c
  26. +++ b/ext/iconv/iconv.c
  27. @@ -697,6 +697,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
  28. iconv_close(cd);
  29. if (result == (size_t)(-1)) {
  30. + zend_string_free(out_buf);
  31. switch (errno) {
  32. case EINVAL:
  33. retval = PHP_ICONV_ERR_ILLEGAL_CHAR;
  34. @@ -713,7 +714,6 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
  35. default:
  36. /* other error */
  37. - zend_string_free(out_buf);
  38. return PHP_ICONV_ERR_UNKNOWN;
  39. }
  40. }
  41. @@ -986,9 +986,6 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval,
  42. err = php_iconv_string(ndl, ndl_nbytes, &ndl_buf, GENERIC_SUPERSET_NAME, enc);
  43. if (err != PHP_ICONV_ERR_SUCCESS) {
  44. - if (ndl_buf != NULL) {
  45. - zend_string_free(ndl_buf);
  46. - }
  47. return err;
  48. }
  49. @@ -2465,9 +2462,6 @@ PHP_NAMED_FUNCTION(php_if_iconv)
  50. if (err == PHP_ICONV_ERR_SUCCESS && out_buffer != NULL) {
  51. RETVAL_STR(out_buffer);
  52. } else {
  53. - if (out_buffer != NULL) {
  54. - zend_string_free(out_buffer);
  55. - }
  56. RETURN_FALSE;
  57. }
  58. }