Skip to content

Commit 0252be9

Browse files
committed
Move ZVAL_DEREF to php_array_fetch
1 parent 75eda25 commit 0252be9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/MongoDB/Query.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ static bool php_phongo_query_opts_append_document(bson_t* opts, const char* opts
5858
zval* value = php_array_fetch(zarr, zarr_key);
5959
bson_t b = BSON_INITIALIZER;
6060

61-
ZVAL_DEREF(value);
6261
if (Z_TYPE_P(value) != IS_OBJECT && Z_TYPE_P(value) != IS_ARRAY) {
6362
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"%s\" %s to be array or object, %s given", zarr_key, zarr_key[0] == '$' ? "modifier" : "option", PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(value));
6463
return false;

src/contrib/php_array_api.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,12 @@ zval *php_array_fetchl(zval *zarr, const char *key, int key_len) {
188188
}
189189
static inline
190190
zval *php_array_fetch(zval *zarr, const char *key) {
191-
return php_array_fetchl(zarr, key, strlen(key));
191+
zval *ret = php_array_fetchl(zarr, key, strlen(key));
192+
if (ret) {
193+
ZVAL_DEREF(ret);
194+
}
195+
196+
return ret;
192197
}
193198
#define php_array_fetchc(zarr, litstr) php_array_fetchl(zarr, litstr, sizeof(litstr)-1)
194199
static inline

0 commit comments

Comments
 (0)