summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--otherlibs/dynlink/dynlink.ml6
1 files changed, 5 insertions, 1 deletions
diff --git a/otherlibs/dynlink/dynlink.ml b/otherlibs/dynlink/dynlink.ml
index 1596e9af1..376104c14 100644
--- a/otherlibs/dynlink/dynlink.ml
+++ b/otherlibs/dynlink/dynlink.ml
@@ -197,10 +197,14 @@ let load_compunit ic file_name compunit =
let loadfile file_name =
init();
+ if not (Sys.file_exists file_name) then raise(Error (File_not_found file_name));
let ic = open_in_bin file_name in
try
let buffer = String.create (String.length Config.cmo_magic_number) in
- really_input ic buffer 0 (String.length Config.cmo_magic_number);
+ begin
+ try really_input ic buffer 0 (String.length Config.cmo_magic_number)
+ with End_of_file -> raise(Error(Not_a_bytecode_file file_name))
+ end;
if buffer = Config.cmo_magic_number then begin
let compunit_pos = input_binary_int ic in (* Go to descriptor *)
seek_in ic compunit_pos;