dfaure added a comment.

  In D28478#645019 <https://phabricator.kde.org/D28478#645019>, @ahmadsamir 
wrote:
  
  > hmm... first this is a copy-paste "error" on my part, I personally never 
use & when the RHS is a temporary (I don't see the point).
  
  
  The point is to avoid a copy ;-)
  
  If the RHS is a value, this extends its lifetime.
  But if it's a reference itself, then indeed we depend on its lifetime....
  
  >   the job may finish and get deleted by the time we call 
entry.numberValue() on line 1534.
  
  That's not a "guess", it's confirmed by what ASAN tells us in its second 
backtrace.
  
  > And maybe statResult() shouldn't return a reference (or a const reference 
for that matter, because if the caller uses 'entry = job->statResult()'
  >  then statResult() returning a const & doesn't make any difference if it's 
copied...).
  
  Well you get two copies then, one at "return" and one at '=' (technically 
that's an assignment, unless entry is actually declared on the same line).
  
  Anyhow the fix is clear, remove the & :-)

REPOSITORY
  R241 KIO

REVISION DETAIL
  https://phabricator.kde.org/D28478

To: ahmadsamir, #frameworks, dfaure, meven, bruns
Cc: kde-frameworks-devel, LeGast00n, cblack, GB_2, michaelh, ngraham, bruns

Reply via email to