Skip to content

Commit

Permalink
Memory leak in space_sparse_vector_inter.cc #165
Browse files Browse the repository at this point in the history
  • Loading branch information
searchivairus committed Jul 20, 2017
1 parent 090e6f7 commit 5b12955
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions similarity_search/src/space/space_sparse_vector_inter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,10 @@ Object* SpaceSparseVectorInter<dist_t>::CreateObjFromVect(IdType id, LabelType l
char *pData = NULL;
size_t dataLen = 0;

try {
PackSparseElements(InpVect, pData, dataLen);
return new Object(id, label, dataLen, pData);
} catch (...) {
delete [] pData;
throw;
}
PackSparseElements(InpVect, pData, dataLen);
unique_ptr<char[]> data(pData);
unique_ptr<Object> obj(new Object(id, label, dataLen, data.get()));
return obj.release();
}

template <typename dist_t>
Expand Down

0 comments on commit 5b12955

Please sign in to comment.