https://bugs.documentfoundation.org/show_bug.cgi?id=159908

            Bug ID: 159908
           Summary: LibreOffice crashes when using a constant as a loop
                    variable in BASIC code, leading to data loss.
           Product: LibreOffice
           Version: 7.6.5.2 release
          Hardware: x86-64 (AMD64)
                OS: Windows (All)
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: BASIC
          Assignee: [email protected]
          Reporter: [email protected]

Description:
When attempting to use a constant as a loop variable in BASIC code within
LibreOffice, the software crashes unexpectedly. This crash results in the loss
of all unsaved data, including any BASIC code snippets related to the
problematic code. This behavior occurs when the constant is used in a loop
context where it is being modified, violating the immutability of constants.

LibreOffice should handle the attempt to modify a constant within a loop
gracefully, displaying an appropriate error message instead of crashing. This
would allow users to correct the code and prevent data loss.

(Note: The BASIC code snippet to reproduce the error is provided in the "Steps
to Reproduce" section below.)

Steps to Reproduce:
Of note: It is crucial to be aware that reproducing this crash leads to severe
data loss, as LibreOffice abruptly terminates, resulting in the deletion of all
unsaved data and any BASIC code snippets related to the problematic code.

Exercise with caution when testing and reproducing this issue, and ensure that
no critical or unsaved work is present to avoid unintended data loss.

1. Open LibreOffice and create a new Basic module.
2. Add the following Basic subroutine

```basic
REM Uncomment the following line to declare "index" as a constant and reproduce
the crash. Otherwise, the code will result in an error ("Variable not
defined").
REM Const index = 0
Sub Example
    Dim sum As Integer : sum = 0
    For index = 0 To 2
        sum = sum + 1
    Next index
End Sub

3. Compile and execute the subroutine.
4. LibreOffice will highlight the "index" and display the following error
message: "BASIC syntax error. Variable expected." Clicking the OK button to
close the message will result in the crash of all LibreOffice instances.

Actual Results:
LibreOffice crashes abruptly, resulting in the loss of all unsaved data. Any
BASIC code snippets related to the problematic code are also deleted.

Expected Results:
When attempting to modify a constant within a loop, LibreOffice should display
an appropriate error message indicating that constants cannot be modified. The
software should gracefully handle the error without crashing, allowing users to
correct the code and prevent data loss.


Reproducible: Always


User Profile Reset: Yes

Additional Info:
Version: 7.6.5.2 (X86_64) / LibreOffice Community
Build ID: 38d5f62f85355c192ef5f1dd47c5c0c0c6d6598b
CPU threads: 20; OS: Windows 10.0 Build 22631; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL threaded Jumbo

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to