Skip to content

Fix data wipe when deleting empty arrays in LSL Array implementation#1

Draft
google-labs-jules[bot] wants to merge 2 commits intomasterfrom
bugfix/lsl-array-delete-empty-14916694509582366806
Draft

Fix data wipe when deleting empty arrays in LSL Array implementation#1
google-labs-jules[bot] wants to merge 2 commits intomasterfrom
bugfix/lsl-array-delete-empty-14916694509582366806

Conversation

@google-labs-jules
Copy link

Fixed a critical bug in setArraySize where deleting an array that is already empty (size 0) would cause llDeleteSubList to be called with start > end, triggering an exclusion range deletion that wiped the entire g_arrayData list. Added a check to ensure llDeleteSubList is only called when there is data to delete.


PR created automatically by Jules for task 14916694509582366806 started by @mcgroarty

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.
@google-labs-jules
Copy link
Author

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants