Skip to content

Commit 5539039

Browse files
pankajsingh88facebook-github-bot
authored andcommitted
add validity check AlignedTableTightAlloc clear method (facebookresearch#3997)
Summary: Pull Request resolved: facebookresearch#3997 Avoid null pointer error by checking that `numel > 0`. It's equivalent of checking`ptr != null` but keeping numel check for consistency. Bug reported in: facebookresearch#3994 Reviewed By: mnorris11 Differential Revision: D65073502 fbshipit-source-id: f9aa56cbcd28fc352d45ef5b8727fa857fbe5345
1 parent efa18da commit 5539039

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

faiss/utils/AlignedTable.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ struct AlignedTableTightAlloc {
6363
}
6464

6565
void clear() {
66-
memset(ptr, 0, nbytes());
66+
if (numel > 0) {
67+
memset(ptr, 0, nbytes());
68+
}
6769
}
6870
size_t size() const {
6971
return numel;

0 commit comments

Comments
 (0)