The mythical bank account

To demonstrate a more complex problem with lifetimes, let's consider a mythical bank account:

  • I am given access to a bank account, legally, of course
  • I decide that I want my friend to have access to it
  • After a certain amount of time, I decide I no longer want access to the account and have my access removed
  • My friend then tries to use the account

When my friend comes to use the account, he is unable to do so, as the reference I had, and which was passed to him, no longer exists. He is trying to use after free (in programming terms) and he is known here as a dangling reference.

It sounds far-fetched, but in development terms, it happens far more frequently than you would possibly give credit for.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset