fix(RuntimeProfile): Fix false deduplication of tokens that are a suffix of last token.#584
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR tightens boundary validation in the comma-list deduplication function Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
048cda5 to
a55ebcb
Compare
|
Actionable comments posted: 0 |
1 similar comment
|
Actionable comments posted: 0 |
|
Can you update your patch description and state in which case the problem occurred. This is useful for later on as well. So I guess in your case you have this here as you said: "...,gost3410,ecc-tc26-gost3410" The deduplication algo looks at Your fix: With your fix it wouldn't match the dup[-1] and we don't even need to look at the check after the |
|
Yes, that's right, that's the problem. Is there anything else that needs to be done to get the PR accepted? It seems "coverage/coveralls" is not working, maybe it should be restarted or something else. |
A description of what the patch fixes would be good. |
|
Done. |
The text should go into the patch description. |
a55ebcb to
8d3cfcd
Compare
Fix a bug where RuntimeProfileDedupStrItems incorrectly removes a
token that is a suffix of the last token in a comma-separated list.
For example, given "...,<token>,...,other-<token>", the function
would wrongly deduplicate "<token>" out of the list.
The root cause is the (dup[slen] == 0) branch in the boundary check,
which handles the last item in the list but does not verify that the
left boundary of the match is valid:
if (((dup[-1] == ',' || dup[-1] == 0) && dup[slen] == exp) ||
(dup[slen] == 0) /* last item in list */)
The fix requires a valid left-side delimiter in all cases:
if ((dup[-1] == ',' || dup[-1] == 0) &&
(dup[slen] == exp || dup[slen] == 0))
Signed-off-by: IWillBurn <eugene.boyarnikov@gmail.com>
8d3cfcd to
4909888
Compare
|
Thanks! |
Fix false deduplication of tokens that are a suffix of last token.
When processing a comma-separated list containing
<token>at an arbitrary location andother-<token>at the end of the list, theRuntimeProfileDedupStrItemsfunction incorrectly deletes<token>as a duplicate.The root cause is in the boundary check when a
strstrfound match at the end of the string:When
<token>is matched as a substring insideother-<token>(the last item), the(dup[slen] == 0)branch triggers without verifying that the left boundary of the match is valid — i.e. that it is preceded by a,or start of string. This causes<token>to be incorrectly deduplicated out of the list.The fix tightens the boundary check to require a valid left-side delimiter in all cases:
This ensures a match is only treated as a true duplicate when both the left boundary and the right boundary are valid.
Summary by CodeRabbit