Skip to content

Commit 1ac1d32

Browse files
committed
Dup before modifying
Because `remove_resource` modifies @my_resources, we can't call it while iterating over the actual @my_resources. The following snippet illustrates why: ``` >> a = [1,2,3,4]; a.each {|elem| a.delete(elem); puts elem } 1 3 => [2, 4] ``` [See rapid7#2002]
1 parent 38e837d commit 1ac1d32

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/msf/core/exploit/http/server.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ def hardcoded_uripath(uri)
230230

231231
# Take care of removing any resources that we created
232232
def cleanup
233-
@my_resources.each do |resource|
233+
# Must dup here because remove_resource modifies @my_resources
234+
@my_resources.dup.each do |resource|
234235
remove_resource(resource)
235236
end
236237

0 commit comments

Comments
 (0)