Fix memory leak when adding empty keyword hashes
nagachika pointed out that ALLOC_N is actually just malloc, so this memory wasn't being freed. This shouldn't be a performance sensitive code path, and will be going away after 2.7, so just allocate a temp buffer that will be freed later by Ruby GC.
This commit is contained in:
parent
b78a345bd6
commit
39c37acf86
@ -241,8 +241,9 @@ add_empty_keyword(int *argc, const VALUE **argv, int *kw_splat)
|
|||||||
if (*kw_splat == RB_PASS_CALLED_KEYWORDS || *kw_splat == RB_PASS_EMPTY_KEYWORDS) {
|
if (*kw_splat == RB_PASS_CALLED_KEYWORDS || *kw_splat == RB_PASS_EMPTY_KEYWORDS) {
|
||||||
if (*kw_splat == RB_PASS_EMPTY_KEYWORDS || rb_empty_keyword_given_p()) {
|
if (*kw_splat == RB_PASS_EMPTY_KEYWORDS || rb_empty_keyword_given_p()) {
|
||||||
int n = *argc;
|
int n = *argc;
|
||||||
VALUE *ptr = ALLOC_N(VALUE,n+1);
|
VALUE v;
|
||||||
|
VALUE *ptr;
|
||||||
|
ptr = rb_alloc_tmp_buffer2(&v, n, sizeof(VALUE));
|
||||||
memcpy(ptr, *argv, sizeof(VALUE)*n);
|
memcpy(ptr, *argv, sizeof(VALUE)*n);
|
||||||
ptr[n] = rb_hash_new();
|
ptr[n] = rb_hash_new();
|
||||||
*argc = ++n;
|
*argc = ++n;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user