aboutsummaryrefslogtreecommitdiffstats
path: root/lib/erl_interface
diff options
context:
space:
mode:
authorJesper Eskilson <[email protected]>2018-05-22 11:14:19 +0200
committerJesper Eskilson <[email protected]>2018-05-22 11:19:03 +0200
commitabce739f6a897c462b3588ce15983eb530d7e080 (patch)
tree78d9ed799990372fb85a1ee64f9315397b065b35 /lib/erl_interface
parentbbb3d151e6329d58b34e526fefb6964677d93104 (diff)
downloadotp-abce739f6a897c462b3588ce15983eb530d7e080.tar.gz
otp-abce739f6a897c462b3588ce15983eb530d7e080.tar.bz2
otp-abce739f6a897c462b3588ce15983eb530d7e080.zip
ERL-629 Do not free() module buffer until it has been used
Diffstat (limited to 'lib/erl_interface')
-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;