From 1ddab9c7b66237ea6dd429fb75e4c81247d88920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Mon, 25 Jan 2016 13:12:50 +0100 Subject: Eliminate run-time system crash in code:load_abs/1 The run-time system would terminate if code:load_abs/1 was called with a filename containing any non-latin1 characters. The reason is that code_server would attempt to construct a module name from the filename using list_to_atom/1 and that atoms currently are limited to the latin1 character set. But how should the error be reported? I have decided to that the simplest and least confusing way is to move the call to list_to_atom/1 to 'code' module and let it crash the calling process. The resulting stack back trace will make it clear what the reason for the crash was. --- lib/kernel/src/code.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/kernel/src/code.erl') diff --git a/lib/kernel/src/code.erl b/lib/kernel/src/code.erl index 352c02562b..7d0102d4ef 100644 --- a/lib/kernel/src/code.erl +++ b/lib/kernel/src/code.erl @@ -142,7 +142,9 @@ ensure_loaded(Mod) when is_atom(Mod) -> %% XXX File as an atom is allowed only for backwards compatibility. -spec load_abs(Filename) -> load_ret() when Filename :: file:filename(). -load_abs(File) when is_list(File); is_atom(File) -> call({load_abs,File,[]}). +load_abs(File) when is_list(File); is_atom(File) -> + Mod = list_to_atom(filename:basename(File)), + call({load_abs,File,Mod}). %% XXX Filename is also an atom(), e.g. 'cover_compiled' -spec load_abs(Filename :: loaded_filename(), Module :: module()) -> load_ret(). -- cgit v1.2.3