Skip to content

Commit

Permalink
Added memory leak checks to travis script
Browse files Browse the repository at this point in the history
Fixed KLVStream memory leaks (#129)
Fixed misc memory leaks (#130)
  • Loading branch information
palemieux committed Sep 16, 2018
1 parent 9378fb5 commit f294b4d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ matrix:
apt:
packages:
- libxerces-c-dev
- valgrind

script:
- mkdir regxmllib/build
- cd regxmllib/build
- cmake ..
- cmake --build .
- ctest .
- ctest -T memcheck .
- sudo make install

- language: java
Expand Down
2 changes: 2 additions & 0 deletions regxmllib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ endforeach()

enable_testing()

include(CTest)

file( GLOB_RECURSE UNIT_TESTS src/test/cpp/*.cpp )
file(COPY "src/test/resources" DESTINATION "${CMAKE_BINARY_DIR}")

Expand Down
1 change: 1 addition & 0 deletions regxmllib/CTestConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(MEMORYCHECK_COMMAND_OPTIONS "--show-leak-kinds=definite --leak-check=full --error-exitcode=1")
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace rxml {
throw std::ios_base::failure("Max BER length exceeded");
}

unsigned char *buf = new unsigned char[bersz];
unsigned char buf[8];

this->read((char*)buf, bersz);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ namespace rxml {
meta_dictionary.subclassesOf[parentauid].insert(def.identification);
}

} else {

delete def_copy;

}
}

Expand All @@ -111,19 +115,21 @@ namespace rxml {
const AUID parentauid = MetaDictionary::createNormalizedAUID(def.memberOf);

meta_dictionary.membersOf[parentauid].insert(def.identification);

} else {

delete def_copy;

}


}


virtual void visit(const PropertyAliasDefinition & def) {
Definition *def_copy = new PropertyAliasDefinition(def);

const AUID parentauid = MetaDictionary::createNormalizedAUID(def.memberOf);

meta_dictionary.membersOf[parentauid].insert(def.identification);

}

virtual void visit(const EnumerationTypeDefinition &def) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ int main(int argc, char **argv) {

doc->release();

delete ft;
}

/* free heap */
Expand All @@ -314,7 +315,7 @@ int main(int argc, char **argv) {

output->release();
ser->release();

delete parser;

xercesc::XMLPlatformUtils::Terminate();

Expand Down

0 comments on commit f294b4d

Please sign in to comment.