aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2018-06-04 16:52:48 +0200
committerGitHub <[email protected]>2018-06-04 16:52:48 +0200
commite5a9686cb1a2b21caa3a692d960a841cd954d0ff (patch)
tree356b931a603ae514070db10444c29e7f26b171d3 /lib
parente5ee505f2177121ad237f931b7c95b5e77f90360 (diff)
parentabce739f6a897c462b3588ce15983eb530d7e080 (diff)
downloadotp-e5a9686cb1a2b21caa3a692d960a841cd954d0ff.tar.gz
otp-e5a9686cb1a2b21caa3a692d960a841cd954d0ff.tar.bz2
otp-e5a9686cb1a2b21caa3a692d960a841cd954d0ff.zip
Merge PR-1823 from jesperes/ERL-629-erl_call-free-before-use OTP-15105
ERL-629 Do not free() module buffer until it has been used
Diffstat (limited to 'lib')
-rw-r--r--lib/erl_interface/src/prog/erl_call.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/erl_interface/src/prog/erl_call.c b/lib/erl_interface/src/prog/erl_call.c
index 7577a07a3e..66265b3e6a 100644
--- a/lib/erl_interface/src/prog/erl_call.c
+++ b/lib/erl_interface/src/prog/erl_call.c
@@ -517,6 +517,15 @@ int erl_call(int argc, char **argv)
}
}
+
+ /*
+ * If we loaded any module source code, we can free the buffer
+ * now. This buffer was allocated in read_stdin().
+ */
+ if (module != NULL) {
+ free(module);
+ }
+
/*
* Eval the Erlang functions read from stdin/
*/
@@ -795,8 +804,6 @@ static int get_module(char **mbuf, char **mname)
*mname = (char *) ei_chk_calloc(i+1, sizeof(char));
memcpy(*mname, start, i);
}
- if (*mbuf)
- free(*mbuf); /* Allocated in read_stdin() */
return len;