Skip to content

Commit

Permalink
Fix memoty leak
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFreeman committed Aug 26, 2023
1 parent b3b01a0 commit 3238f21
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ext-src/php_swoole_cxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ class Variable {
}

~Variable() {
del_ref();
zval_ptr_dtor(&value);
}
};

Expand Down
4 changes: 4 additions & 0 deletions ext-src/php_swoole_http_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ static inline void http_server_add_server_array(HashTable *ht, zend_string *key,
zend_hash_add(ht, key, &tmp);
}

static inline void http_server_add_server_array(HashTable *ht, zend_string *key, zval *value) {
zend_hash_add(ht, key, value);
}

static inline void http_server_set_object_fd_property(zend_object *object, zend_class_entry *ce, long fd) {
zval *zv = zend_hash_find(&ce->properties_info, SW_ZSTR_KNOWN(SW_ZEND_STR_FD));
zend_property_info *property_info = (zend_property_info *) Z_PTR_P(zv);
Expand Down
2 changes: 1 addition & 1 deletion ext-src/swoole_http_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int php_swoole_http_server_onReceive(Server *serv, RecvData *req) {
iter = rs.first;
}
iter->second.add_ref();
zend_hash_add(ht, SW_ZSTR_KNOWN(SW_ZEND_STR_REMOTE_ADDR), iter->second.ptr());
http_server_add_server_array(ht, SW_ZSTR_KNOWN(SW_ZEND_STR_REMOTE_ADDR), iter->second.ptr());
} else {
http_server_add_server_array(ht, SW_ZSTR_KNOWN(SW_ZEND_STR_REMOTE_ADDR), conn->info.get_ip());
}
Expand Down

0 comments on commit 3238f21

Please sign in to comment.