Domanda

I am trying to pass some data to an object stored in an zval, inside a php extension with this code, and I receive segmentation fault error

[core:notice] [pid 8645] AH00052: child pid 8649 exit signal Segmentation fault (11)

Does anyone can help me to understand why I get this error and what is the right way to call an object method?

thanks!

    //create zval with the data
    zval *zbuffer;
    MAKE_STD_ZVAL(zbuffer);
    ZVAL_STRINGL(zbuffer, WS_G(buffer), WS_G(bufferLen), 1);

    ///push data in object
    zval *retval_ptr;
    zend_call_method( *WS_G(zobj), ce, NULL, "push",  strlen("push"),  &retval_ptr, 1, zbuffer, NULL TSRMLS_CC );
È stato utile?

Soluzione

It seems that the problem were on how I was creating the zbuffer ZVAL the right code is:

    zval *zbuffer;
    MAKE_STD_ZVAL(zbuffer);
    Z_TYPE_P(zbuffer) = IS_STRING;
    Z_STRVAL_P(zbuffer) = WS_G(buffer);
    Z_STRLEN_P(zbuffer) = WS_G(bufferLen);

Thanks!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top