aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-16 23:41:06 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-16 23:51:22 +0900
commit53e9908d8afc7f03109b0aafd1698ab35f512b05 (patch)
tree453b5977d99a2218dd4fac9f662835ebab33665f /parse.y
parentd4929f518562b4e346af57f724232595b674f2b0 (diff)
downloadruby-53e9908d8afc7f03109b0aafd1698ab35f512b05.tar.gz
Fix memory leak
* string.c (str_replace_shared_without_enc): free previous buffer before replaced. * parse.y (gettable): make sure in advance that the `__FILE__` object shares a fstring, to get rid of replacement with the fstring later. TODO: this hack may be needed in other places. [Bug #15916] Co-Authored-By: luke-gru (Luke Gruber) <luke.gru@gmail.com>
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y2
1 files changed, 1 insertions, 1 deletions
diff --git a/parse.y b/parse.y
index a7cdddcaec..d76d3b2562 100644
--- a/parse.y
+++ b/parse.y
@@ -9748,7 +9748,7 @@ gettable(struct parser_params *p, ID id, const YYLTYPE *loc)
if (NIL_P(file))
file = rb_str_new(0, 0);
else
- file = rb_str_dup(file);
+ file = rb_str_dup(rb_fstring(file));
node = NEW_STR(add_mark_object(p, file), loc);
}
return node;