From 593847a0e063522bef780ebac4f4072cf4cae6d8 Mon Sep 17 00:00:00 2001 From: "reed@android.com" Date: Tue, 25 Aug 2009 18:14:50 +0000 Subject: [PATCH] fix overflow in qsort compare proc git-svn-id: http://skia.googlecode.com/svn/trunk@335 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/core/SkScan_Path.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/SkScan_Path.cpp b/src/core/SkScan_Path.cpp index 211259f..636478d 100644 --- a/src/core/SkScan_Path.cpp +++ b/src/core/SkScan_Path.cpp @@ -383,7 +383,11 @@ extern "C" { valuea = edgea->fX; valueb = edgeb->fX; } - return valuea - valueb; + + // this overflows if valuea >>> valueb or vice-versa + // return valuea - valueb; + // do perform the slower but safe compares + return (valuea < valueb) ? -1 : (valuea > valueb); } } -- 2.7.4