Почему php_base64_encode() использует zend_string_safe_alloc() [https://github.com/php/php-src/blob/a2e83346134c7a197492cb520ad440e0e1aff463/ext/standard/base64.c#L745],, а его аналог php_base64_decode_ex() использует zend_string_alloc() [https://github.com/php/php-src/blob/a2e83346134c7a197492cb520ad440e0e1aff463/ext/standard/base64.c#L766] для создания строки Zend в php src?
php_base64_encode()
zend_string_safe_alloc()
php_base64_decode_ex()
zend_string_alloc()
Когда записываете расширение, вызовите php_base64_encode()
zend_string *ret = php_base64_encode(buf, buf_len); RETURN_STR(ret);
без необходимости освобождать zend_string ret, в то время как вызов php_base64_decode(buf, buf_len); без zend_string_release() вызовет
ret
php_base64_decode(buf, buf_len);
zend_string_release()
Zend/zend_string.h(121) : Freeing 0x7F330266A000 (1248 bytes), ... === Total 1 memory leaks detected ===