diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2014-06-03 21:48:17 -0500 |
---|---|---|
committer | Guillermo Iguaran <guilleiguaran@gmail.com> | 2014-06-03 21:48:17 -0500 |
commit | 4818bb36ac1a2a98bc61839ba87a654a78faadbe (patch) | |
tree | 0608127b947cef90440275144509b9360e8f4ae0 /actionpack/lib | |
parent | e4efa187f0e7e62dc99ca3028d47ef17833e6a35 (diff) | |
parent | e63be2769c039e4e9ada523a8497ce3206cc8a9b (diff) | |
download | rails-4818bb36ac1a2a98bc61839ba87a654a78faadbe.tar.gz rails-4818bb36ac1a2a98bc61839ba87a654a78faadbe.tar.bz2 rails-4818bb36ac1a2a98bc61839ba87a654a78faadbe.zip |
Merge pull request #15498 from zenspider/fix_memory_leak
Convert StrongParameters cache to a hash. This fixes an unbounded memory leak
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/metal/strong_parameters.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb index d86d49c9dc..265048a308 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -130,7 +130,7 @@ module ActionController # looping in the common use case permit + mass-assignment. Defined in a # method to instantiate it only if needed. def converted_arrays - @converted_arrays ||= Set.new + @converted_arrays ||= {} end # Returns +true+ if the parameter is permitted, +false+ otherwise. @@ -333,15 +333,15 @@ module ActionController private def convert_hashes_to_parameters(key, value, assign_if_converted=true) - converted = convert_value_to_parameters(value) + converted = convert_value_to_parameters(key, value) self[key] = converted if assign_if_converted && !converted.equal?(value) converted end - def convert_value_to_parameters(value) - if value.is_a?(Array) && !converted_arrays.member?(value) - converted = value.map { |_| convert_value_to_parameters(_) } - converted_arrays << converted + def convert_value_to_parameters(key, value) + if value.is_a?(Array) && !converted_arrays.member?(key) + converted = value.map { |v| convert_value_to_parameters(nil, v) } + converted_arrays[key] = converted if key converted elsif value.is_a?(Parameters) || !value.is_a?(Hash) value |