• Haruto Otake's avatar
    BITCOUNT: fix segmentation fault. · 749aac72
    Haruto Otake authored
    remove unsafe and unnecessary cast.
    until now, this cast may lead segmentation fault when end > UINT_MAX
    
    setbit foo 0 1
    bitcount  0 4294967295
    => ok
    bitcount  0 4294967296
    => cause segmentation fault.
    
    Note by @antirez: the commit was modified a bit to also change the
    string length type to long, since it's guaranteed to be at max 512 MB in
    size, so we can work with the same type across all the code path.
    
    A regression test was also added.
    749aac72
bitops.tcl 5.16 KB