Skip to content

Commit

Permalink
Merge pull request #497 from sys-bio/leak-fix
Browse files Browse the repository at this point in the history
Fix memory leak
  • Loading branch information
andrewhu-uw committed Sep 7, 2018
2 parents cd7044a + 13698fd commit 41e17fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ before_install:

install:
- cd ~/build/roadrunner
- cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/install/roadrunner -DTHIRD_PARTY_INSTALL_FOLDER=/usr -DLLVM_CONFIG_EXECUTABLE=/usr/lib/llvm-3.5/bin/llvm-config -DBUILD_PYTHON=ON -DPYTHON_EXECUTABLE=/usr/bin/python -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython2.7.so python2.7 -DBUILD_TESTS=ON -DBUILD_TEST_TOOLS=ON -DUSE_TR1_CXX_NS=OFF -DBUILD_JAVA_INTERFACE=OFF "$TRAVIS_BUILD_DIR"
- cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/install/roadrunner -DTHIRD_PARTY_INSTALL_FOLDER=/usr -DLLVM_CONFIG_EXECUTABLE=/usr/lib/llvm-3.5/bin/llvm-config -DBUILD_PYTHON=ON -DPYTHON_EXECUTABLE=/usr/bin/python -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython2.7.so python2.7 -DBUILD_TESTS=ON -DBUILD_TEST_TOOLS=ON -DUSE_TR1_CXX_NS=ON -DBUILD_JAVA_INTERFACE=OFF "$TRAVIS_BUILD_DIR"
- make -j2
- make install

Expand Down
12 changes: 9 additions & 3 deletions source/SBMLValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ bool isStoichDefined(const std::string sbml) {
if (!doc)
throw std::runtime_error("Unable to read SBML");

if (doc->getLevel() < 3)
if (doc->getLevel() < 3) {
delete doc;
return true; // stoichiometry has a default value in level 1 & 2
}

const Model *m = doc->getModel();

Expand All @@ -154,13 +156,17 @@ bool isStoichDefined(const std::string sbml) {

// check stoich defined on reactants / products
for (int k = 0; k<r->getNumReactants(); ++k) {
if (!isStoichDefined(r->getReactant(k)))
if (!isStoichDefined(r->getReactant(k))) {
delete doc;
return false;
}
}

for (int k = 0; k<r->getNumProducts(); ++k) {
if (!isStoichDefined(r->getProduct(k)))
if (!isStoichDefined(r->getProduct(k))) {
delete doc;
return false;
}
}

// modifiers have no stoichiometry
Expand Down

0 comments on commit 41e17fc

Please sign in to comment.