Repository navigation
fix: prevent crash when removing last dropdown option in removeValue - #2843
Conversation
Bug #6 from Faultmark scan (issue documenso#2829): after splice(index, 1), the code checked newValues[index].value — but newValues[index] is the element that shifted into that position. If the removed item was the last one, newValues[index] is undefined -> runtime crash. The defaultValue was also never correctly cleared. Fix: Capture removedValue from currentValues (before splice) for safe comparison. Signed-off-by: Abdulazez A. <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
|
Hey there, it looks like you haven't accepted our contributor license agreement yet. In order for us to accept your pull request we ask that you please fill out the CLA: https://documen.so/cla |
Summary
Fixes bug #6 from the Faultmark scan (issue #2829):
removeValuecrashes when removing the last item from the dropdown options list.Root cause
After
newValues.splice(index, 1), the code checkednewValues[index].value. ButnewValues[index]is the element that shifted into that position after the splice. If the removed item was the last one,newValues[index]isundefined-> runtime crash.Fix
Capture the
removedValuefromcurrentValues[index].valuebefore the splice, then comparedefaultValueagainst the captured value.Partially addresses #2829