Skip to content

Commit 3ec1589

Browse files
committed
Ensure refcount is initialized when constructing zval *.
1 parent a74920b commit 3ec1589

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/messages.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ class MessageToJs : public Message {
295295
// asynchronously from the PHP side.
296296
ZVal closureRetval{ZEND_FILE_LINE_C};
297297
// Use plain zval to avoid allocating copy of method name.
298-
zval method; ZVAL_STRINGL(&method, "call", 4, 0);
298+
zval method; INIT_ZVAL(method); ZVAL_STRINGL(&method, "call", 4, 0);
299299
zval *args[] = { e.Ptr(), r.Ptr() };
300300
if (FAILURE == call_user_function(EG(function_table),
301301
php_callback_.PtrPtr(), &method,

src/node_php_embed.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static int node_php_embed_ub_write(const char *str,
6161
ZVal stream{ZEND_FILE_LINE_C}, retval{ZEND_FILE_LINE_C};
6262
worker->GetStream().ToPhp(channel, stream TSRMLS_CC);
6363
// Use plain zval to avoid allocating copy of method name.
64-
zval method; ZVAL_STRINGL(&method, "write", 5, 0);
64+
zval method; INIT_ZVAL(method); ZVAL_STRINGL(&method, "write", 5, 0);
6565
// Special buffer type to pass `str` as a node buffer and avoid copying.
6666
zval buffer, *args[] = { &buffer }; INIT_ZVAL(buffer);
6767
node_php_embed::node_php_jsbuffer_create(&buffer, str, str_length,
@@ -89,7 +89,7 @@ static void node_php_embed_flush(void *server_context) {
8989
ZVal stream{ZEND_FILE_LINE_C}, retval{ZEND_FILE_LINE_C};
9090
worker->GetStream().ToPhp(channel, stream TSRMLS_CC);
9191
// Use plain zval to avoid allocating copy of method name.
92-
zval method; ZVAL_STRINGL(&method, "write", 5, 0);
92+
zval method; INIT_ZVAL(method); ZVAL_STRINGL(&method, "write", 5, 0);
9393
// Special buffer type to pass `str` as a node buffer and avoid copying.
9494
zval buffer; INIT_ZVAL(buffer);
9595
node_php_embed::node_php_jsbuffer_create(&buffer, "", 0,
@@ -123,7 +123,7 @@ static void node_php_embed_send_header(sapi_header_struct *sapi_header,
123123
// Use plain zval to avoid allocating copy of method name.
124124
// The "sendHeader" method is a special JS-side method to translate
125125
// headers into node.js format.
126-
zval method; ZVAL_STRINGL(&method, "sendHeader", 10, 0);
126+
zval method; INIT_ZVAL(method); ZVAL_STRINGL(&method, "sendHeader", 10, 0);
127127
// Special buffer type to pass `str` as a node buffer and avoid copying.
128128
zval buffer, *args[] = { &buffer }; INIT_ZVAL(buffer);
129129
if (sapi_header) { // NULL is passed to indicate "last call"
@@ -152,8 +152,8 @@ static int node_php_embed_read_post(char *buffer, uint count_bytes TSRMLS_DC) {
152152
ZVal stream{ZEND_FILE_LINE_C}, retval{ZEND_FILE_LINE_C};
153153
worker->GetStream().ToPhp(channel, stream TSRMLS_CC);
154154
// Use plain zval to avoid allocating copy of method name.
155-
zval method; ZVAL_STRINGL(&method, "read", 4, 0);
156-
zval size; ZVAL_LONG(&size, count_bytes);
155+
zval method; INIT_ZVAL(method); ZVAL_STRINGL(&method, "read", 4, 0);
156+
zval size; INIT_ZVAL(size); ZVAL_LONG(&size, count_bytes);
157157
// Create the special JsWait object.
158158
zval wait; INIT_ZVAL(wait);
159159
node_php_embed::node_php_jswait_create(&wait TSRMLS_CC);

src/node_php_jsobject_class.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ ZEND_END_ARG_INFO()
517517
PHP_METHOD(JsObject, __tostring) {
518518
// Implement `__tostring` by calling JS `toString` method.
519519
// Use plain zval to avoid allocating copy of method name
520-
zval method; ZVAL_STRINGL(&method, "toString", 8, 0);
520+
zval method; INIT_ZVAL(method); ZVAL_STRINGL(&method, "toString", 8, 0);
521521
zval *args = nullptr;
522522
call_user_function(EG(function_table), &this_ptr, &method,
523523
return_value, 0, &args TSRMLS_CC);

src/node_php_jsserver_class.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ PHP_METHOD(JsServer, __get) {
106106
*return_value_ptr = *retval;
107107
}
108108
#else
109-
ZVAL_BOOL(return_value, true);
109+
RETVAL_BOOL(true);
110110
#endif
111111
TRACE("<");
112112
}
@@ -125,7 +125,7 @@ PHP_METHOD(JsServer, __set) {
125125
// This is the whole point of this class!
126126
php_register_variable_ex(Z_STRVAL_P(member), value.Transfer(TSRMLS_C),
127127
obj->track_vars_array TSRMLS_CC);
128-
ZVAL_BOOL(return_value, true);
128+
RETVAL_BOOL(true);
129129
TRACE("<");
130130
}
131131

0 commit comments

Comments
 (0)