From dde3c9e8d8d585017c09201f98ba804bb24e4134 Mon Sep 17 00:00:00 2001 From: mwilliams Date: Wed, 19 Jun 2013 07:48:34 -0700 Subject: [PATCH] Fix tvSame for null-by-reference values The dereference was too late. --- hphp/runtime/base/tv_comparisons.cpp | 6 +++--- hphp/test/slow/comparisons/refnull.php | 5 +++++ hphp/test/slow/comparisons/refnull.php.expect | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 hphp/test/slow/comparisons/refnull.php create mode 100644 hphp/test/slow/comparisons/refnull.php.expect diff --git a/hphp/runtime/base/tv_comparisons.cpp b/hphp/runtime/base/tv_comparisons.cpp index 839822a3c..72b8123d0 100644 --- a/hphp/runtime/base/tv_comparisons.cpp +++ b/hphp/runtime/base/tv_comparisons.cpp @@ -391,14 +391,14 @@ bool tvSame(const TypedValue* tv1, const TypedValue* tv2) { assert(tvIsPlausible(tv1)); assert(tvIsPlausible(tv2)); + tv1 = tvToCell(tv1); + tv2 = tvToCell(tv2); + bool const null1 = IS_NULL_TYPE(tv1->m_type); bool const null2 = IS_NULL_TYPE(tv2->m_type); if (null1 && null2) return true; if (null1 || null2) return false; - tv1 = tvToCell(tv1); - tv2 = tvToCell(tv2); - switch (tv1->m_type) { case KindOfInt64: case KindOfBoolean: diff --git a/hphp/test/slow/comparisons/refnull.php b/hphp/test/slow/comparisons/refnull.php new file mode 100644 index 000000000..c3495491b --- /dev/null +++ b/hphp/test/slow/comparisons/refnull.php @@ -0,0 +1,5 @@ +