From 74e7eba528510c0b2c95c50e251685e738e28fee Mon Sep 17 00:00:00 2001 From: James Tanner Date: Fri, 8 Nov 2013 13:17:02 -0500 Subject: [PATCH] Fixes #4506 test length of context before checking invalid indexes --- lib/ansible/module_utils/basic.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index a7af7167af..a15f0b31f0 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -348,10 +348,12 @@ class AnsibleModule(object): # argument context, which may have selevel. for i in range(len(cur_context)): - if context[i] is not None and context[i] != cur_context[i]: - new_context[i] = context[i] - if context[i] is None: - new_context[i] = cur_context[i] + if len(context) > i: + if context[i] is not None and context[i] != cur_context[i]: + new_context[i] = context[i] + if context[i] is None: + new_context[i] = cur_context[i] + if cur_context != new_context: try: if self.check_mode: