SkNextLog2 requires positive values.
authorbungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 30 Jan 2013 21:23:13 +0000 (21:23 +0000)
committerbungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 30 Jan 2013 21:23:13 +0000 (21:23 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@7474 2bbb7eff-a529-9590-31e7-b0007b416f81

src/core/SkTSort.h

index 0eeb068..fbdb55b 100644 (file)
@@ -191,8 +191,11 @@ template <typename T, typename C> void SkTIntroSort(int depth, T* left, T* right
  *  @param lessThan a functor with bool operator()(T a, T b) which returns true if a comes before b.
  */
 template <typename T, typename C> void SkTQSort(T* left, T* right, C lessThan) {
+    if (left >= right) {
+        return;
+    }
     ptrdiff_t size = right - left;
-    int depth = SkNextLog2(SkToU32(size + 1));
+    int depth = SkNextLog2(SkToU32(size));
     SkTIntroSort(depth * 2, left, right, lessThan);
 }