Skip to content

Commit

Permalink
Fix infinite loops in GetClassName
Browse files Browse the repository at this point in the history
The plugin was revesing the list inside a "for in" loop iterating on the
same list, which could cause infinite loops if the reversing happening in
a "flip-flop" style. Added copy()-s to the offending lines.

Fixes #64
  • Loading branch information
dudu committed Apr 28, 2015
1 parent 877a797 commit 12d56a3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions autoload/phpcomplete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1935,7 +1935,7 @@ function! phpcomplete#GetClassName(start_line, context, current_namespace, impor

" function declaration line
if line =~? 'function\(\s\+'.function_name_pattern.'\)\?\s*('
let function_lines = join(reverse(lines), " ")
let function_lines = join(reverse(copy(lines)), " ")
" search for type hinted arguments
if function_lines =~? 'function\(\s\+'.function_name_pattern.'\)\?\s*(.\{-}'.class_name_pattern.'\s\+'.object && !object_is_array
let f_args = matchstr(function_lines, '\cfunction\(\s\+'.function_name_pattern.'\)\?\s*(\zs.\{-}\ze)')
Expand Down Expand Up @@ -1976,7 +1976,7 @@ function! phpcomplete#GetClassName(start_line, context, current_namespace, impor

" try to find the next non-comment or string ";" char
let start_col = match(line, '^\s*'.object.'\C\s*=\zs&\?\s\+\(clone\)\?\s*'.variable_name_pattern)
let filelines = reverse(lines)
let filelines = reverse(copy(lines))
let [pos, char] = s:getNextCharWithPos(filelines, [a:start_line - i - 1, start_col])
let chars_read = 1
let last_pos = pos
Expand Down

0 comments on commit 12d56a3

Please sign in to comment.