From: Gustavo André dos Santos Lopes Date: Tue, 21 Dec 2010 17:29:14 +0000 (+0000) Subject: - Fixed bug #53588 (SplMinHeap bad sorting with custom compare X-Git-Tag: php-5.4.0alpha1~191^2~472 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a11d76a75513272e93b92c571ee857506294179;p=php - Fixed bug #53588 (SplMinHeap bad sorting with custom compare function). --- diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c index d2fffd45a5..c162f6f069 100644 --- a/ext/spl/spl_heap.c +++ b/ext/spl/spl_heap.c @@ -176,7 +176,7 @@ static int spl_ptr_heap_zval_min_cmp(spl_ptr_heap_element a, spl_ptr_heap_elemen spl_heap_object *heap_object = (spl_heap_object*)zend_object_store_get_object((zval *)object TSRMLS_CC); if (heap_object->fptr_cmp) { long lval = 0; - if (spl_ptr_heap_cmp_cb_helper((zval *)object, heap_object, (zval *)a, (zval *)b, &lval TSRMLS_CC) == FAILURE) { + if (spl_ptr_heap_cmp_cb_helper((zval *)object, heap_object, (zval *)b, (zval *)a, &lval TSRMLS_CC) == FAILURE) { /* exception or call failure */ return 0; } diff --git a/ext/spl/tests/bug53588.phpt b/ext/spl/tests/bug53588.phpt new file mode 100644 index 0000000000..1546908c35 --- /dev/null +++ b/ext/spl/tests/bug53588.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #53588 (SplMinHeap bad sorting with custom compare function) +--FILE-- +insert( 8 ); +$obj->insert( 0 ); +$obj->insert( 4 ); + +foreach( $obj as $number ) { + echo $number, "\n"; +} +--EXPECT-- +0 +4 +8 +