Hi, Thanks for the quick responses and for the repo.
You are right about one of the remarks. xmp_ptr should only be allocated in case xmp_create_context() is successful. I updated the code; https://github.com/bor0/xmp/commit/4a49b9816bf5cf405fd06de6470170611fb0519b However, about the other remark, xmp_create_context() can return NULL in case of alloc failure, as shown here http://fossies.org/dox/libxmp-4.2.8/control_8c_source.html#l00036 (it seems to not be documented). Best regards, Boro Sitnikovski On Tuesday, September 9, 2014 12:41 AM, Johannes Schlüter <[email protected]> wrote: Hi, On Fri, 2014-09-05 at 05:05 -0700, Boro Sitnikovski wrote: > Hi Johannes, > > Thanks for the remarks. I've pushed a new commit that fixes them. PHP_FUNCTION(xmp_create_context) { /* ... */ xmp = xmp_create_context(); memcpy(xmp_ptr, &xmp, sizeof(xmp_context)); if (xmp) { ZEND_REGISTER_RESOURCE(return_value, xmp_ptr, le_xmp); } else { RETURN_FALSE; } } this still looks suspicious to me. You always copy contents of xmp to xmp_ptr and only later check value of xmp. Quick look at docs tells me that xmp_create_context() apparently can't report an error and something like this might be enough: PHP_FUNCTION(xmp_create_context) { xmp_context *xmp; if (zend_parse_parameters_none() == FAILURE) { return; } xmp = emalloc(sizeof(xmp_context)); *xmp = xmp_create_context(); ZEND_REGISTER_RESOURCE(return_value, xmp, le_xmp); } > I requested a PECL account using that form. Creating the repo is in the works. johannes -- PECL development discussion Mailing List (http://pecl.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
