Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed dbBlock::duplicate which causes memory corruption issues #6536

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions src/odb/include/odb/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -1728,17 +1728,6 @@ class dbBlock : public dbObject
dbTech* tech = nullptr,
char hier_delimeter = 0);

///
/// duplicate - Make a duplicate of the specified "child" block. If name ==
/// nullptr, the name of the block is also duplicated. If the duplicated block
/// does not have a unique name, then "findChild" may return an incorrect
/// block. UNIQUE child-block-names are not enforced! (This should be fixed)!
///
/// A top-block can not be duplicated. This methods returns nullptr if the
/// specified block has not parent.
///
static dbBlock* duplicate(dbBlock* block, const char* name = nullptr);

///
/// Translate a database-id back to a pointer.
///
Expand Down
28 changes: 0 additions & 28 deletions src/odb/src/db/dbBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3158,34 +3158,6 @@ dbBlock* dbBlock::create(dbBlock* parent_,
return (dbBlock*) child;
}

dbBlock* dbBlock::duplicate(dbBlock* child_, const char* name_)
{
_dbBlock* child = (_dbBlock*) child_;

// must be a child block
if (child->_parent == 0) {
return nullptr;
}

_dbBlock* parent = (_dbBlock*) child_->getParent();
_dbChip* chip = (_dbChip*) child->getOwner();

// make a copy
_dbBlock* dup = chip->_block_tbl->duplicate(child);

// link child-to-parent
parent->_children.push_back(dup->getOID());
dup->_parent = parent->getOID();

if (name_ && dup->_name) {
free((void*) dup->_name);
dup->_name = strdup(name_);
ZALLOCATED(dup->_name);
}

return (dbBlock*) dup;
}

dbBlock* dbBlock::getBlock(dbChip* chip_, uint dbid_)
{
_dbChip* chip = (_dbChip*) chip_;
Expand Down
Loading