oleaut32: Added a preliminary test, for scale overflow, in VarDecCmp. (try 3)
Christopher Cope
ccope3 at utk.edu
Tue Oct 22 09:47:17 CDT 2013
This fixes Bug #31269 <http://bugs.winehq.org/show_bug.cgi?id=31269>.
---
dlls/oleaut32/tests/vartype.c | 2 +-
dlls/oleaut32/vartype.c | 32 +++++++++++++++++++++++++++++++-
2 files changed, 32 insertions(+), 2 deletions(-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20131022/656bed66/attachment.html>
-------------- next part --------------
From 76cd73ce0ff971f3e67e5e52edeead8fee1d6549 Mon Sep 17 00:00:00 2001
From: Christopher Cope <ccope3 at utk.edu>
Date: Tue, 22 Oct 2013 10:42:14 -0400
Subject: oleaut32: Added a preliminary test, for scale overflow, in
VarDecCmp.
---
dlls/oleaut32/tests/vartype.c | 2 +-
dlls/oleaut32/vartype.c | 32 +++++++++++++++++++++++++++++++-
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/dlls/oleaut32/tests/vartype.c b/dlls/oleaut32/tests/vartype.c
index e296e77..7649a98 100644
--- a/dlls/oleaut32/tests/vartype.c
+++ b/dlls/oleaut32/tests/vartype.c
@@ -4513,7 +4513,7 @@ static void test_VarDecCmp(void)
SETDEC(out,0,DECIMAL_NEG,-1,-1); SETDEC(l,0,DECIMAL_NEG,-1,-1); MATH1(VarDecCmp); EXPECT_EQ;
SETDEC(l,3,0,0,123456); SETDEC64(out,0,0,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
- MATH1(VarDecCmp); todo_wine EXPECT_LT;
+ MATH1(VarDecCmp); EXPECT_LT;
}
static void test_VarDecCmpR8(void)
diff --git a/dlls/oleaut32/vartype.c b/dlls/oleaut32/vartype.c
index d492e7d..9b2dfb5 100644
--- a/dlls/oleaut32/vartype.c
+++ b/dlls/oleaut32/vartype.c
@@ -5836,7 +5836,8 @@ HRESULT WINAPI VarDecRound(const DECIMAL* pDecIn, int cDecimals, DECIMAL* pDecOu
HRESULT WINAPI VarDecCmp(const DECIMAL* pDecLeft, const DECIMAL* pDecRight)
{
HRESULT hRet;
- DECIMAL result;
+ DECIMAL result, decTemp, scaleFactor;
+ int scaleAmount, i;
if (!pDecLeft || !pDecRight)
return VARCMP_NULL;
@@ -5848,6 +5849,35 @@ HRESULT WINAPI VarDecCmp(const DECIMAL* pDecLeft, const DECIMAL* pDecRight)
(DEC_HI32(pDecLeft) | DEC_MID32(pDecLeft) | DEC_LO32(pDecLeft)))
return VARCMP_LT;
+ /* Preliminary check for scale overflow */
+ DEC_LO32(&scaleFactor) = 10;
+ i = scaleAmount = DEC_SCALE(pDecLeft) - DEC_SCALE(pDecRight);
+ if(scaleAmount != 0)
+ {
+ if(scaleAmount > 0)
+ {
+ decTemp = *pDecRight; /* Left is bigger - scale the right hand side */
+ }
+ else
+ {
+ decTemp = *pDecLeft; /* Right is bigger - scale the left hand side */
+ i = scaleAmount = -scaleAmount;
+ }
+ }
+ while(i--)
+ {
+ /* Note we are multiplying by a value with a scale of 0, so we don't recurse */
+ hRet = VarDecMul(&decTemp, &scaleFactor, &result);
+ if(hRet == DISP_E_OVERFLOW)
+ {
+ if(scaleAmount > 0) // Right is bigger
+ return (HRESULT)VARCMP_LT;
+ else // Left is bigger
+ return (HRESULT)VARCMP_GT;
+ }
+ decTemp = result;
+ }
+
/* Subtract right from left, and compare the result to 0 */
hRet = VarDecSub(pDecLeft, pDecRight, &result);
--
1.7.9
More information about the wine-patches
mailing list