unsigned char *s = (unsigned char *) SvPV(sv, srclen);
UV retnum = 0;
- if (offset < 0 || size < 1)
+ if (offset < 0)
return retnum;
+ if (size < 1 || (size & (size-1))) /* size < 1 or not a power of two */
+ Perl_croak(aTHX_ "Illegal number of bits in vec");
offset *= size; /* turn into bit offset */
len = (offset + size + 7) / 8; /* required number of bytes */
if (len > srclen) {
((UV) s[offset + 1] << 16) +
( s[offset + 2] << 8);
}
- else
- Perl_croak(aTHX_ "Illegal number of bits in vec");
}
}
else if (size < 8)
((UV) s[offset + 1] << 16) +
( s[offset + 2] << 8) +
s[offset + 3];
- else
- Perl_croak(aTHX_ "Illegal number of bits in vec");
}
return retnum;
lval = SvUV(sv);
offset = LvTARGOFF(sv);
size = LvTARGLEN(sv);
+ if (size < 1 || (size & (size-1))) /* size < 1 or not a power of two */
+ Perl_croak(aTHX_ "Illegal number of bits in vec");
offset *= size; /* turn into bit offset */
len = (offset + size + 7) / 8; /* required number of bytes */