ext/hnswlib/src/bruteforce.h in hnswlib-0.6.0 vs ext/hnswlib/src/bruteforce.h in hnswlib-0.6.1
- old
+ new
@@ -27,11 +27,11 @@
std::runtime_error("Not enough memory: BruteforceSearch failed to allocate data");
cur_element_count = 0;
}
~BruteforceSearch() {
- free(data_);
+ if (data_) free(data_);
}
char *data_;
size_t maxelements_;
size_t cur_element_count;
@@ -127,9 +127,13 @@
void loadIndex(const std::string &location, SpaceInterface<dist_t> *s) {
std::ifstream input(location, std::ios::binary);
+
+ if (!input.is_open())
+ throw std::runtime_error("Cannot open file");
+
std::streampos position;
readBinaryPOD(input, maxelements_);
readBinaryPOD(input, size_per_element_);
readBinaryPOD(input, cur_element_count);