]> git.sur5r.net Git - openldap/commitdiff
Fix carries
authorHoward Chu <hyc@openldap.org>
Sat, 1 Dec 2007 11:14:40 +0000 (11:14 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 1 Dec 2007 11:14:40 +0000 (11:14 +0000)
libraries/liblutil/utils.c

index 30738c869c262a7c738d1e27575e01aaa5018ace..a96fa060cf42a0d357ffbf6fa6c97668c9845362 100644 (file)
@@ -638,6 +638,9 @@ scale( int new, lutil_int_decnum *prev, unsigned char *tmp )
                                part >>= 8;
                        }
                }
+               j++;
+               prev->beg += j;
+               prev->len -= j;
        }
 
        out = tmp + prev->bufsiz;
@@ -648,8 +651,11 @@ scale( int new, lutil_int_decnum *prev, unsigned char *tmp )
                out[i] = new & 0xff;
                new >>= 8;
        } while ( new );
-       prev->beg = prev->bufsiz + i;
-       prev->len = -i;
+       i = -i;
+       if ( prev->len < i ) {
+               prev->beg = prev->bufsiz - i;
+               prev->len = i;
+       }
        AC_MEMCPY( prev->buf+prev->beg, tmp+prev->beg, prev->len );
 }