From e427e312d4942566e42114d7098661f8a6062cd3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gustavo=20Andr=C3=A9=20dos=20Santos=20Lopes?= Date: Tue, 21 Dec 2010 17:29:14 +0000 Subject: [PATCH] - Fixed bug #53588 (SplMinHeap bad sorting with custom compare function). --- NEWS | 2 ++ ext/spl/spl_heap.c | 2 +- ext/spl/tests/bug53588.phpt | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 ext/spl/tests/bug53588.phpt diff --git a/NEWS b/NEWS index 849d9ddb80..20b20f9956 100644 --- a/NEWS +++ b/NEWS @@ -70,6 +70,8 @@ - SPL extension: . Fixed bug #53515 (property_exists incorrect on ArrayObject null and 0 values). (Felipe) + . Fixed bug #53588 (SplMinHeap bad sorting with custom compare function). + (Gustavo) - SQLite extension: . Fixed memory leaked introduced by the NULL poisoning patch (Mateusz Kocielski, Pierre) diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c index f729478388..52f2008cdb 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 + -- 2.40.0