Skip to content

Commit

Permalink
Avoid deleting incomplete type (shogun-toolbox#4095)
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn authored and ktiefe committed Jul 26, 2019
1 parent 2ae6141 commit 2801aef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/shogun/base/class_list.cpp.templ
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@ CSGObject* shogun::create(const char* classname, EPrimitiveType generic)

return NULL;
}

void shogun::delete_object(CSGObject* object)
{
delete object;
}
7 changes: 6 additions & 1 deletion src/shogun/base/class_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ namespace shogun {
*/
CSGObject* create(const char* sgserializable_name, EPrimitiveType generic);

/** deletes object
* @param object pointer to object to be deleted
*/
void delete_object(CSGObject* object);

/** Creates new shogun instance, typed.
*
* Throws an exception in case there is no such classname or
Expand All @@ -39,7 +44,7 @@ namespace shogun {
auto* cast = dynamic_cast<T*>(object);
if (!cast)
{
delete object;
delete_object(object);
SG_SERROR("Type mismatch");
}
cast->ref();
Expand Down

0 comments on commit 2801aef

Please sign in to comment.