1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

string.c: fix String#crypt leak introduced in r58866

* string.c (rb_str_crypt): define LARGE_CRYPT_DATA when allocating

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2017-05-24 21:26:14 +00:00
parent daf14f713f
commit 2079b71000
2 changed files with 5 additions and 1 deletions

View file

@ -8727,7 +8727,7 @@ rb_str_crypt(VALUE str, VALUE salt)
# if defined SIZEOF_CRYPT_DATA && SIZEOF_CRYPT_DATA <= 256
struct crypt_data cdata, *const data = &cdata;
# else
# undef LARGE_CRYPT_DATA
# define LARGE_CRYPT_DATA
struct crypt_data *data = ALLOC(struct crypt_data);
# endif
#else

View file

@ -546,6 +546,10 @@ CODE
assert_raise(ArgumentError) {S("mypassword").crypt(S("aa".encode(enc)))}
assert_raise(ArgumentError) {S("mypassword".encode(enc)).crypt(S("aa"))}
end
@cls == String and assert_no_memory_leak([], 's = ""', <<~'end;') # do
1000.times { s.crypt(-"..").clear }
end;
end
def test_delete