Skip to content

Commit 46f6002

Browse files
bjoriderickr
authored andcommitted
PHPC-431: Segfault when using Manager through singleton class
1 parent 5d21863 commit 46f6002

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

phongo_compat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
# define SUPPRESS_UNUSED_WARNING(x)
157157
# define DECLARE_RETURN_VALUE_USED int return_value_used = 1;
158158
# define EXCEPTION_P(_ex, _zp) ZVAL_OBJ(&_zp, _ex)
159-
# define PHONGO_STREAM_ID(stream) stream->res->handle
159+
# define PHONGO_STREAM_ID(stream) stream->res ? stream->res->handle : -1
160160
# define ADD_ASSOC_STRING(_zv, _key, _value) add_assoc_string_ex(_zv, ZEND_STRL(_key), _value);
161161
# define ADD_ASSOC_STRINGL(_zv, _key, _value, _len) add_assoc_stringl_ex(_zv, ZEND_STRL(_key), _value, _len);
162162
# define ADD_ASSOC_LONG_EX(_zv, _key, _value) add_assoc_long_ex(_zv, ZEND_STRL(_key), _value);

php_phongo.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,9 @@ void phongo_stream_failed(mongoc_stream_t *stream_wrap) /* {{{ */
732732
php_phongo_stream_socket *base_stream = (php_phongo_stream_socket *)stream_wrap;
733733

734734
if (base_stream->stream) {
735+
#if PHP_VERSION_ID < 70000
735736
PHONGO_TSRMLS_FETCH_FROM_CTX(base_stream->tsrm_ls);
737+
#endif
736738

737739
MONGOC_DEBUG("Destroying RSRC#%d", PHONGO_STREAM_ID(base_stream->stream));
738740
php_stream_free(base_stream->stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR);
@@ -748,7 +750,9 @@ int phongo_stream_close(mongoc_stream_t *stream_wrap) /* {{{ */
748750

749751
MONGOC_DEBUG("Closing RSRC#%d", PHONGO_STREAM_ID(base_stream->stream));
750752
if (base_stream->stream) {
753+
#if PHP_VERSION_ID < 70000
751754
TSRMLS_FETCH_FROM_CTX(base_stream->tsrm_ls);
755+
#endif
752756

753757
MONGOC_DEBUG("Destroying RSRC#%d", PHONGO_STREAM_ID(base_stream->stream));
754758
php_stream_free(base_stream->stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR);

0 commit comments

Comments
 (0)