Why php_base64_encode()
uses zend_string_safe_alloc()
[https://github.com/php/php-src/blob/a2e83346134c7a197492cb520ad440e0e1aff463/ext/standard/base64.c#L745], while its counterpart php_base64_decode_ex()
uses zend_string_alloc()
[https://github.com/php/php-src/blob/a2e83346134c7a197492cb520ad440e0e1aff463/ext/standard/base64.c#L766] to create a zend string in php src?
When writes an extension, call php_base64_encode()
zend_string *ret = php_base64_encode(buf, buf_len);
RETURN_STR(ret);
no need to release the zend_string ret
, while call php_base64_decode(buf, buf_len);
without zend_string_release()
will cause
Zend/zend_string.h(121) : Freeing 0x7F330266A000 (1248 bytes), ...
=== Total 1 memory leaks detected ===