lib/gitlab/search/found_blob.rb is using instance var unsafely

In lib/gitlab/search/found_blob.rb, we have the binary_path method and the @binary_path instance var.

  • Initializer intializes @binary_path or defaults to nil
  • #binary_path method sets and memoizes @binary_path too
  • #path method uses @binary_path ivar directly.

Is it possible to have a bug where path returns different values depending on whether binary_path is called prior ?

See also discussion from !18470 (merged) should be addressed:

NB: This was a pre-existing issue even before !18470 (merged)

  • @tkuah started a discussion: (+3 comments)

    This is very odd. @binary_path can be different things depending on what order one calls:

    • binary_path then path
    • path then binary_path

    Do we know any reason why path is using the ivar @binary_path instead of using binary_path ?

Edited Oct 23, 2019 by Thong Kuah
Assignee Loading
Time tracking Loading