Skip to content

Commit 7850762

Browse files
committed
Fixup
1 parent be65b64 commit 7850762

20 files changed

+44
-41
lines changed

php_phongo.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ ZEND_TSRMLS_CACHE_EXTERN()
6060

6161
zend_object_handlers* phongo_get_std_object_handlers(void);
6262

63+
#define PHONGO_RETURN_PROPS(is_temp, props) \
64+
if (!(is_temp)) { \
65+
GC_ADDREF(props); \
66+
} \
67+
return props;
68+
6369
#define PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, size) \
6470
do { \
6571
if (!(intern)->php_properties) { \

src/BSON/Binary.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static HashTable* php_phongo_binary_get_properties_hash(zend_object* object, boo
7373
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, 2);
7474

7575
if (!intern->data) {
76-
return props;
76+
PHONGO_RETURN_PROPS(is_temp, props);
7777
}
7878

7979
{
@@ -86,7 +86,7 @@ static HashTable* php_phongo_binary_get_properties_hash(zend_object* object, boo
8686
zend_hash_str_update(props, "type", sizeof("type") - 1, &type);
8787
}
8888

89-
return props;
89+
PHONGO_RETURN_PROPS(is_temp, props);
9090
}
9191

9292
/* Construct a new BSON binary type */

src/BSON/DBPointer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ HashTable* php_phongo_dbpointer_get_properties_hash(zend_object* object, bool is
7474
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, 2);
7575

7676
if (!intern->ref) {
77-
return props;
77+
PHONGO_RETURN_PROPS(is_temp, props);
7878
}
7979

8080
{
@@ -86,7 +86,7 @@ HashTable* php_phongo_dbpointer_get_properties_hash(zend_object* object, bool is
8686
zend_hash_str_update(props, "id", sizeof("id") - 1, &id);
8787
}
8888

89-
return props;
89+
PHONGO_RETURN_PROPS(is_temp, props);
9090
}
9191

9292
PHONGO_DISABLED_CONSTRUCTOR(MongoDB_BSON_DBPointer)

src/BSON/Decimal128.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static HashTable* php_phongo_decimal128_get_properties_hash(zend_object* object,
6464
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, 1);
6565

6666
if (!intern->initialized) {
67-
return props;
67+
PHONGO_RETURN_PROPS(is_temp, props);
6868
}
6969

7070
bson_decimal128_to_string(&intern->decimal, outbuf);
@@ -76,7 +76,7 @@ static HashTable* php_phongo_decimal128_get_properties_hash(zend_object* object,
7676
zend_hash_str_update(props, "dec", sizeof("dec") - 1, &dec);
7777
}
7878

79-
return props;
79+
PHONGO_RETURN_PROPS(is_temp, props);
8080
}
8181

8282
/* Construct a new BSON Decimal128 type */

src/BSON/Document.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static HashTable* php_phongo_document_get_properties_hash(zend_object* object, b
6565
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, size);
6666

6767
if (!intern->bson) {
68-
return props;
68+
PHONGO_RETURN_PROPS(is_temp, props);
6969
}
7070

7171
{
@@ -75,7 +75,7 @@ static HashTable* php_phongo_document_get_properties_hash(zend_object* object, b
7575
zend_hash_str_update(props, "data", sizeof("data") - 1, &data);
7676
}
7777

78-
return props;
78+
PHONGO_RETURN_PROPS(is_temp, props);
7979
}
8080

8181
PHONGO_DISABLED_CONSTRUCTOR(MongoDB_BSON_Document)
@@ -527,7 +527,7 @@ static HashTable* php_phongo_document_get_debug_info(zend_object* object, int* i
527527
zend_hash_str_update(props, "value", sizeof("value") - 1, &state.zchild);
528528
}
529529

530-
return props;
530+
PHONGO_RETURN_PROPS(is_temp, props);
531531

532532
failure:
533533
PHONGO_GET_PROPERTY_HASH_FREE_PROPS(is_temp, props);

src/BSON/Int64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ HashTable* php_phongo_int64_get_properties_hash(zend_object* object, bool is_tem
7272
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, 2);
7373

7474
if (!intern->initialized) {
75-
return props;
75+
PHONGO_RETURN_PROPS(is_temp, props);
7676
}
7777

7878
{
@@ -82,7 +82,7 @@ HashTable* php_phongo_int64_get_properties_hash(zend_object* object, bool is_tem
8282
zend_hash_str_update(props, "integer", sizeof("integer") - 1, &value);
8383
}
8484

85-
return props;
85+
PHONGO_RETURN_PROPS(is_temp, props);
8686
}
8787

8888
static PHP_METHOD(MongoDB_BSON_Int64, __construct)

src/BSON/Iterator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static HashTable* php_phongo_iterator_get_properties_hash(zend_object* object, b
165165
zend_hash_str_update(props, "bson", sizeof("bson") - 1, &intern->bson);
166166
Z_TRY_ADDREF(intern->bson);
167167

168-
return props;
168+
PHONGO_RETURN_PROPS(is_temp, props);
169169
}
170170

171171
PHONGO_DISABLED_CONSTRUCTOR(MongoDB_BSON_Iterator)

src/BSON/Javascript.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ HashTable* php_phongo_javascript_get_properties_hash(zend_object* object, bool i
7979
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, 2);
8080

8181
if (!intern->code) {
82-
return props;
82+
PHONGO_RETURN_PROPS(is_temp, props);
8383
}
8484

8585
{
@@ -106,7 +106,7 @@ HashTable* php_phongo_javascript_get_properties_hash(zend_object* object, bool i
106106
}
107107
}
108108

109-
return props;
109+
PHONGO_RETURN_PROPS(is_temp, props);
110110

111111
failure:
112112
PHONGO_GET_PROPERTY_HASH_FREE_PROPS(is_temp, props);

src/BSON/ObjectId.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static HashTable* php_phongo_objectid_get_properties_hash(zend_object* object, b
8787
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, 1);
8888

8989
if (!intern->initialized) {
90-
return props;
90+
PHONGO_RETURN_PROPS(is_temp, props);
9191
}
9292

9393
{
@@ -96,11 +96,8 @@ static HashTable* php_phongo_objectid_get_properties_hash(zend_object* object, b
9696
ZVAL_STRING(&zv, intern->oid);
9797
zend_hash_str_update(props, "oid", sizeof("oid") - 1, &zv);
9898
}
99-
if (!is_temp) {
100-
GC_ADDREF(props);
101-
}
10299

103-
return props;
100+
PHONGO_RETURN_PROPS(is_temp, props);
104101
}
105102

106103
/* Constructs a new BSON ObjectId type, optionally from a hex string. */

src/BSON/PackedArray.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static HashTable* php_phongo_packedarray_get_properties_hash(zend_object* object
6666
PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, size);
6767

6868
if (!intern->bson) {
69-
return props;
69+
PHONGO_RETURN_PROPS(is_temp, props);
7070
}
7171

7272
{
@@ -76,7 +76,7 @@ static HashTable* php_phongo_packedarray_get_properties_hash(zend_object* object
7676
zend_hash_str_update(props, "data", sizeof("data") - 1, &data);
7777
}
7878

79-
return props;
79+
PHONGO_RETURN_PROPS(is_temp, props);
8080
}
8181

8282
static bool php_phongo_packedarray_to_json(zval* return_value, bson_json_mode_t mode, const bson_t* bson)
@@ -512,7 +512,7 @@ static HashTable* php_phongo_packedarray_get_debug_info(zend_object* object, int
512512
zend_hash_str_update(props, "value", sizeof("value") - 1, &state.zchild);
513513
}
514514

515-
return props;
515+
PHONGO_RETURN_PROPS(is_temp, props);
516516

517517
failure:
518518
PHONGO_GET_PROPERTY_HASH_FREE_PROPS(is_temp, props);

0 commit comments

Comments
 (0)