From: Richard W.M. Jones Date: Fri, 4 Jul 2008 12:35:06 +0000 (+0000) Subject: Don't allow zero-length patterns to be loaded from a file X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=8567d2641afef70642c59bf23f26e79f2e567443;p=ocaml-bitstring.git Don't allow zero-length patterns to be loaded from a file --- diff --git a/pa_bitmatch.ml b/pa_bitmatch.ml index ef4d8eb..98151a3 100644 --- a/pa_bitmatch.ml +++ b/pa_bitmatch.ml @@ -791,7 +791,10 @@ let load_patterns_from_file _loc filename = let names = List.rev !names in List.iter ( function - | name, P.Pattern patt -> add_named_pattern _loc name patt + | name, P.Pattern patt -> + if patt = [] then + locfail _loc (sprintf "pattern %s: no fields" name); + add_named_pattern _loc name patt | _, P.Constructor _ -> () (* just ignore these for now *) ) names