Skip to content

rocksdb: pointers with pointer member #15

@qqiangwu

Description

@qqiangwu
  void DeleteRecoveredTransaction(const std::string& name) {
    auto it = recovered_transactions_.find(name);
    assert(it != recovered_transactions_.end());
    auto* trx = it->second;
    recovered_transactions_.erase(it);
    for (const auto& info : trx->batches_) {
      logs_with_prep_tracker_.MarkLogAsHavingPrepSectionFlushed(
          info.second.log_number_);
    }
    delete trx;
  }

got:

/Users/wuqq/dev/rocksdb-main/db/db_impl/db_impl.h:1045:27: warning: dereferencing a dangling pointer
 1045 |     for (const auto& info : trx->batches_) {
      |                           ^
/Users/wuqq/dev/rocksdb-main/db/db_impl/db_impl.h:1044:35: note: modified here
 1044 |     recovered_transactions_.erase(it);
      |                                   ^~

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions