gtoubassi / femtozip

FemtoZip is a "shared dictionary" compression library optimized for small documents that may not compress well with traditional tools such as gzip
Other
146 stars 23 forks source link

CPP Femtozip Infinite Loop in IntSet.h #8

Open canselcik opened 10 years ago

canselcik commented 10 years ago

When provided with a large quantity of files/data, femtozip gets into an infinite loop. This issue can be tracked down to the insert(int, int*, int*, size_t) method in IntSet.h.

inline int insert(int n, int *b, int *end, size_t capacity) {
    int *p = b + (n % capacity);
    while (*p != -1) {
        if (*p == n) {
            return 0;
        }
        p++;
        if (p == end) {
            p = b;
        }
    }  
    *p = n;
    return 1;
}

The loop while (*p != -1) never completes as p is never equal to -1 or n.