From afff8b0fd74fda09ba8dc5f7bfe95b5cb345872e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 23 Mar 2016 07:00:34 +0100 Subject: Fix compile:forms/1,2 crash when not in an existing directory compile:forms/1,2 will crash when the current working directory has been deleted. Fix that problem, and while we are at it, also stop including {source,""} in module_info() when no source code file is given. Reported-at: http://bugs.erlang.org/browse/ERL-113 Reported-by: Adam Lindberg --- lib/compiler/src/beam_asm.erl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/compiler/src/beam_asm.erl') diff --git a/lib/compiler/src/beam_asm.erl b/lib/compiler/src/beam_asm.erl index 95be471de3..28fd061bdc 100644 --- a/lib/compiler/src/beam_asm.erl +++ b/lib/compiler/src/beam_asm.erl @@ -225,10 +225,14 @@ flatten_imports(Imps) -> list_to_binary(map(fun({M,F,A}) -> <> end, Imps)). build_attributes(Opts, SourceFile, Attr, MD5) -> + Misc0 = case SourceFile of + [] -> []; + [_|_] -> [{source,SourceFile}] + end, Misc = case member(slim, Opts) of false -> {{Y,Mo,D},{H,Mi,S}} = erlang:universaltime(), - [{time,{Y,Mo,D,H,Mi,S}},{source,SourceFile}]; + [{time,{Y,Mo,D,H,Mi,S}}|Misc0]; true -> [] end, Compile = [{options,Opts},{version,?COMPILER_VSN}|Misc], -- cgit v1.2.3