From: Richard W.M. Jones Date: Wed, 4 Apr 2012 09:40:42 +0000 (+0000) Subject: takebits/dropbits: check that n >= 0 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=8760d65b505c4a363065aaf299ef835f44884333;p=ocaml-bitstring.git takebits/dropbits: check that n >= 0 http://code.google.com/p/bitstring/issues/detail?id=18 --- diff --git a/bitstring.ml b/bitstring.ml index 8a9ef3e..efac383 100644 --- a/bitstring.ml +++ b/bitstring.ml @@ -136,11 +136,11 @@ let subbitstring (data, off, len) off' len' = let dropbits n (data, off, len) = let off = off + n in let len = len - n in - if len < 0 then invalid_arg "dropbits"; + if len < 0 || n < 0 then invalid_arg "dropbits"; (data, off, len) let takebits n (data, off, len) = - if len < n then invalid_arg "takebits"; + if len < n || n < 0 then invalid_arg "takebits"; (data, off, n) (*----------------------------------------------------------------------*)