fix: guard extra_info pointer arithmetic against nullptr in BruteForce::Add#2168
fix: guard extra_info pointer arithmetic against nullptr in BruteForce::Add#2168LHT129 wants to merge 1 commit into
Conversation
…e::Add When extra_info is nullptr, performing pointer arithmetic (nullptr + offset) is undefined behavior in C++. Add a null check before the arithmetic, consistent with the pattern already used in warp.cpp. Signed-off-by: LHT129 <tianlan.lht@antgroup.com> Co-authored-by: opencode <opencode@anthropic.com>
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Require kind labelWonderful, this rule succeeded.
🟢 Require version labelWonderful, this rule succeeded.
🟢 Require linked issue for feature/bug PRsWonderful, this rule succeeded.
|
There was a problem hiding this comment.
Code Review
This pull request updates the brute-force algorithm implementation to safely handle cases where extra_info is null. It introduces a helper pointer ei_ptr to prevent undefined behavior from pointer arithmetic on a null pointer. There are no review comments, so I have no additional feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR fixes undefined behavior in BruteForce::Add by preventing pointer arithmetic on a null extra_info pointer, aligning the implementation with the existing null-guard pattern used elsewhere (e.g., warp.cpp).
Changes:
- Add a per-element
ei_ptrcomputed viaextra_info == nullptr ? nullptr : extra_info + j * extra_info_size. - Use
ei_ptrfor both the threaded (GeneralEnqueue) and non-threaded (add_func) add paths.
Fixes: #2167
Summary
When
extra_infoisnullptr(the common case when no extra info is provided),BruteForce::Addperformsnullptr + j * extra_info_size, which is undefined behavior in C++.This PR adds a null check before the pointer arithmetic, consistent with the pattern already used in
warp.cpp:189.Changes
src/algorithm/bruteforce/bruteforce.cpp: Extractei_ptrwith null check before passing toGeneralEnqueue/add_funcTest plan