Skip to content
This repository has been archived by the owner on Oct 30, 2021. It is now read-only.

Fix two errors identified by clang-tidy #109

Merged
merged 1 commit into from
Sep 4, 2017

Conversation

springmeyer
Copy link
Contributor

@springmeyer springmeyer commented Aug 18, 2017

clang-tidy is a static analyzer capable of detecting a wide range of bugs and memory leaks.

@mapbox/core-tech is spearheading getting clang-tidy working for node c++ modules at mapbox/node-cpp-skel#63.

In time we will provide docs for how to enable on clang-tidy on travis for carmen-cache.

Currently I ran clang-tidy locally to assess the codebase here and found two problems worth fixing quickly.

The following PR fixes a potential memory leak and incorrect usage of std::move. The incorrect std::move usage is minor. The memory leak could trigger if a new RocksDBCache is created in JS using an invalid or empty string, or if the database cannot be opened.

/cc @GretaCB

 - avoid leaking memory when error is throw
 - incorrect usage of std::move which prevents copy elison

Detected using the setup from mapbox/node-cpp-skel#63
@yhahn yhahn merged commit 9ad6782 into master Sep 4, 2017
@springmeyer springmeyer deleted the fix-memleak-and-pessimizing-move branch September 5, 2017 16:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants