fix bucket key segfault when converted into pair
This commit is contained in:
parent
7d60aff7e4
commit
5e3518a5ec
|
@ -56,16 +56,17 @@
|
||||||
#define BUCKET_2_PAIR(pair, bucket) \
|
#define BUCKET_2_PAIR(pair, bucket) \
|
||||||
{ \
|
{ \
|
||||||
zval _key; \
|
zval _key; \
|
||||||
if (bucket->key) \
|
if ((bucket)->key) \
|
||||||
{ \
|
{ \
|
||||||
ZVAL_STR(&_key, bucket->key); \
|
GC_ADDREF((bucket)->key); \
|
||||||
|
ZVAL_STR(&_key, (bucket)->key); \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
ZVAL_LONG(&_key, bucket->h); \
|
ZVAL_LONG(&_key, (bucket)->h); \
|
||||||
} \
|
} \
|
||||||
PAIR_UPDATE_FIRST(pair, &_key); \
|
PAIR_UPDATE_FIRST(pair, &_key); \
|
||||||
PAIR_UPDATE_SECOND(pair, &bucket->val); \
|
PAIR_UPDATE_SECOND(pair, &(bucket)->val); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CALLBACK_KEYVAL_INVOKE(params, bucket) \
|
#define CALLBACK_KEYVAL_INVOKE(params, bucket) \
|
||||||
|
@ -179,7 +180,9 @@ static int bucket_compare_userland(const void* op1, const void* op2)
|
||||||
ZVAL_COPY_VALUE(¶ms[0], &b1->val);
|
ZVAL_COPY_VALUE(¶ms[0], &b1->val);
|
||||||
ZVAL_COPY_VALUE(¶ms[1], &b2->val);
|
ZVAL_COPY_VALUE(¶ms[1], &b2->val);
|
||||||
zend_call_function(FCI_G, FCC_G);
|
zend_call_function(FCI_G, FCC_G);
|
||||||
return ZEND_NORMALIZE_BOOL(zval_get_long(&retval));
|
int result = ZEND_NORMALIZE_BOOL(zval_get_long(&retval));
|
||||||
|
zval_ptr_dtor(&retval);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int count_collection(zval* obj, zend_long* count)
|
int count_collection(zval* obj, zend_long* count)
|
||||||
|
|
|
@ -12,7 +12,7 @@ $by_b = function($p1, $p2) {
|
||||||
return $p1->second['b'] - $p2->second['b'];
|
return $p1->second['b'] - $p2->second['b'];
|
||||||
};
|
};
|
||||||
$by_c = function($p1, $p2) {
|
$by_c = function($p1, $p2) {
|
||||||
return $p1->second['c'] - $p2->second['c'];
|
return strval($p1->second['c'] - $p2->second['c']);
|
||||||
};
|
};
|
||||||
if ($collection->minWith($by_b) != $array['a'] || $collection->minWith($by_c) != $array['d'])
|
if ($collection->minWith($by_b) != $array['a'] || $collection->minWith($by_c) != $array['d'])
|
||||||
echo 'Collection::minWith() failed.', PHP_EOL;
|
echo 'Collection::minWith() failed.', PHP_EOL;
|
||||||
|
|
Reference in New Issue