Skip to content

Commit

Permalink
Ensure refcount is initialized when constructing zval *.
Browse files Browse the repository at this point in the history
  • Loading branch information
cscott committed Nov 3, 2015
1 parent a74920b commit 3ec1589
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ class MessageToJs : public Message {
// asynchronously from the PHP side.
ZVal closureRetval{ZEND_FILE_LINE_C};
// Use plain zval to avoid allocating copy of method name.
zval method; ZVAL_STRINGL(&method, "call", 4, 0);
zval method; INIT_ZVAL(method); ZVAL_STRINGL(&method, "call", 4, 0);
zval *args[] = { e.Ptr(), r.Ptr() };
if (FAILURE == call_user_function(EG(function_table),
php_callback_.PtrPtr(), &method,
Expand Down
10 changes: 5 additions & 5 deletions src/node_php_embed.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static int node_php_embed_ub_write(const char *str,
ZVal stream{ZEND_FILE_LINE_C}, retval{ZEND_FILE_LINE_C};
worker->GetStream().ToPhp(channel, stream TSRMLS_CC);
// Use plain zval to avoid allocating copy of method name.
zval method; ZVAL_STRINGL(&method, "write", 5, 0);
zval method; INIT_ZVAL(method); ZVAL_STRINGL(&method, "write", 5, 0);
// Special buffer type to pass `str` as a node buffer and avoid copying.
zval buffer, *args[] = { &buffer }; INIT_ZVAL(buffer);
node_php_embed::node_php_jsbuffer_create(&buffer, str, str_length,
Expand Down Expand Up @@ -89,7 +89,7 @@ static void node_php_embed_flush(void *server_context) {
ZVal stream{ZEND_FILE_LINE_C}, retval{ZEND_FILE_LINE_C};
worker->GetStream().ToPhp(channel, stream TSRMLS_CC);
// Use plain zval to avoid allocating copy of method name.
zval method; ZVAL_STRINGL(&method, "write", 5, 0);
zval method; INIT_ZVAL(method); ZVAL_STRINGL(&method, "write", 5, 0);
// Special buffer type to pass `str` as a node buffer and avoid copying.
zval buffer; INIT_ZVAL(buffer);
node_php_embed::node_php_jsbuffer_create(&buffer, "", 0,
Expand Down Expand Up @@ -123,7 +123,7 @@ static void node_php_embed_send_header(sapi_header_struct *sapi_header,
// Use plain zval to avoid allocating copy of method name.
// The "sendHeader" method is a special JS-side method to translate
// headers into node.js format.
zval method; ZVAL_STRINGL(&method, "sendHeader", 10, 0);
zval method; INIT_ZVAL(method); ZVAL_STRINGL(&method, "sendHeader", 10, 0);
// Special buffer type to pass `str` as a node buffer and avoid copying.
zval buffer, *args[] = { &buffer }; INIT_ZVAL(buffer);
if (sapi_header) { // NULL is passed to indicate "last call"
Expand Down Expand Up @@ -152,8 +152,8 @@ static int node_php_embed_read_post(char *buffer, uint count_bytes TSRMLS_DC) {
ZVal stream{ZEND_FILE_LINE_C}, retval{ZEND_FILE_LINE_C};
worker->GetStream().ToPhp(channel, stream TSRMLS_CC);
// Use plain zval to avoid allocating copy of method name.
zval method; ZVAL_STRINGL(&method, "read", 4, 0);
zval size; ZVAL_LONG(&size, count_bytes);
zval method; INIT_ZVAL(method); ZVAL_STRINGL(&method, "read", 4, 0);
zval size; INIT_ZVAL(size); ZVAL_LONG(&size, count_bytes);
// Create the special JsWait object.
zval wait; INIT_ZVAL(wait);
node_php_embed::node_php_jswait_create(&wait TSRMLS_CC);
Expand Down
2 changes: 1 addition & 1 deletion src/node_php_jsobject_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ ZEND_END_ARG_INFO()
PHP_METHOD(JsObject, __tostring) {
// Implement `__tostring` by calling JS `toString` method.
// Use plain zval to avoid allocating copy of method name
zval method; ZVAL_STRINGL(&method, "toString", 8, 0);
zval method; INIT_ZVAL(method); ZVAL_STRINGL(&method, "toString", 8, 0);
zval *args = nullptr;
call_user_function(EG(function_table), &this_ptr, &method,
return_value, 0, &args TSRMLS_CC);
Expand Down
4 changes: 2 additions & 2 deletions src/node_php_jsserver_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ PHP_METHOD(JsServer, __get) {
*return_value_ptr = *retval;
}
#else
ZVAL_BOOL(return_value, true);
RETVAL_BOOL(true);
#endif
TRACE("<");
}
Expand All @@ -125,7 +125,7 @@ PHP_METHOD(JsServer, __set) {
// This is the whole point of this class!
php_register_variable_ex(Z_STRVAL_P(member), value.Transfer(TSRMLS_C),
obj->track_vars_array TSRMLS_CC);
ZVAL_BOOL(return_value, true);
RETVAL_BOOL(true);
TRACE("<");
}

Expand Down

0 comments on commit 3ec1589

Please sign in to comment.