• arendjr@programming.devOP
    link
    fedilink
    arrow-up
    31
    ·
    edit-2
    4 days ago

    Using smart pointers doesn’t eliminate the memory safety issue, it merely addresses one aspect of it. Even with smart pointers, nothing is preventing you from passing references and using them after they’re freed.

    • refalo@programming.dev
      link
      fedilink
      arrow-up
      2
      arrow-down
      10
      ·
      4 days ago

      To be fair, it’s entirely possible to make the same and very similar mistakes in Rust, too.

      • GetOffMyLan@programming.dev
        link
        fedilink
        arrow-up
        8
        arrow-down
        1
        ·
        edit-2
        4 days ago

        I’m fairly sure use after free isn’t possible unless you explicitly use unsafe code right?

        It’s compiler enforced is the point.