Skip to content

Commit 93aa0e9

Browse files
pankajsingh88facebook-github-bot
authored andcommitted
add validity check AlignedTableTightAlloc clear method
Summary: 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: #3994 Differential Revision: D65073502
1 parent efa18da commit 93aa0e9

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)