diff options
| author | herbelin | 2010-06-22 06:28:37 +0000 |
|---|---|---|
| committer | herbelin | 2010-06-22 06:28:37 +0000 |
| commit | a1f06f016be512c21cb475491ec9924eea7ff288 (patch) | |
| tree | ac2a62bef05382047475fdca5cb6a42989772499 /lib | |
| parent | 629048d0bc2a7210eed268ee6484deb2cc11141c (diff) | |
Protection against anomaly when loading a state with bad magic number.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@13175 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/system.ml | 7 | ||||
| -rw-r--r-- | lib/system.mli | 2 |
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/system.ml b/lib/system.ml index 854c5dbdb0..e0ec7b3ea3 100644 --- a/lib/system.ml +++ b/lib/system.ml @@ -255,6 +255,13 @@ let extern_intern ?(warn=true) magic suffix = in (extern_state,intern_state) +let with_magic_number_check f a = + try f a + with Bad_magic_number fname -> + errorlabstrm "with_magic_number_check" + (str"File " ++ str fname ++ strbrk" has bad magic number." ++ spc () ++ + strbrk "It is corrupted or was compiled with another version of Coq.") + (* Communication through files with another executable *) let connect writefun readfun com = diff --git a/lib/system.mli b/lib/system.mli index 86bff1d88e..13fd09f5fb 100644 --- a/lib/system.mli +++ b/lib/system.mli @@ -57,6 +57,8 @@ val raw_extern_intern : int -> string -> val extern_intern : ?warn:bool -> int -> string -> (string -> 'a -> unit) * (load_path -> string -> 'a) +val with_magic_number_check : ('a -> 'b) -> 'a -> 'b + (** {6 Sending/receiving once with external executable } *) val connect : (out_channel -> unit) -> (in_channel -> 'a) -> string -> 'a |
