Fix data wipe when deleting empty arrays in LSL Array implementation#1
Fix data wipe when deleting empty arrays in LSL Array implementation#1google-labs-jules[bot] wants to merge 2 commits intomasterfrom
Conversation
When `setArraySize` is called to remove an array (size 0), if the array to be removed is already empty (`oldSize == 0`), the calculation `dataOffset + oldSize - 1` results in `dataOffset - 1`. Calling `llDeleteSubList(g_arrayData, dataOffset, dataOffset - 1)` triggers the LSL behavior where `start > end` creates an exclusion range, deleting everything *except* the range between end and start. Since `start` and `end` are adjacent, this effectively deletes the entire list. This commit adds a check `if (oldSize > 0)` to skip the data deletion step if the array is already empty, preventing the data wipe.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
When `setArraySize` is called to remove an array (size 0), if the array to be removed is already empty (`oldSize == 0`), the calculation `dataOffset + oldSize - 1` results in `dataOffset - 1`. Calling `llDeleteSubList(g_arrayData, dataOffset, dataOffset - 1)` triggers the LSL behavior where `start > end` creates an exclusion range, deleting everything *except* the range between end and start. Since `start` and `end` are adjacent, this effectively deletes the entire list. This commit adds a check `if (oldSize > 0)` to skip the data deletion step if the array is already empty, preventing the data wipe. Also includes `test_fix.lsl` for verification in Second Life.
Fixed a critical bug in
setArraySizewhere deleting an array that is already empty (size 0) would causellDeleteSubListto be called withstart > end, triggering an exclusion range deletion that wiped the entireg_arrayDatalist. Added a check to ensurellDeleteSubListis only called when there is data to delete.PR created automatically by Jules for task 14916694509582366806 started by @mcgroarty