changeset 6855:128af7cac045 libavcodec

Use an intermediate variable for overflow testing
author vitor
date Sat, 24 May 2008 16:38:48 +0000
parents d4c8338a09a8
children 94465a2c3b34
files ra144.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ra144.c	Sat May 24 16:20:37 2008 +0000
+++ b/ra144.c	Sat May 24 16:38:48 2008 +0000
@@ -154,19 +154,22 @@
 
     for (i=0; i<len; i++) {
         int sum = 0;
+        int new_val;
 
         for(x=0; x<10; x++)
             sum += i1[9-x] * ptr[x];
 
         sum >>= 12;
 
-        if (ptr[10] - sum < -32768 || ptr[10] - sum > 32767) {
+        new_val = ptr[10] - sum;
+
+        if (new_val < -32768 || new_val > 32767) {
             memset(out, 0, len * 2);
             memset(statbuf, 0, 20);
             return;
         }
 
-        ptr[10] -= sum;
+        ptr[10] = new_val;
         ptr++;
     }