Bug 150135 - Accessing uninitialized TextInputStream methods crashes
Summary: Accessing uninitialized TextInputStream methods crashes
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: difficultyBeginner, easyHack, skillCpp
Depends on:
Blocks: Crash
  Show dependency treegraph
 
Reported: 2022-07-25 09:41 UTC by Mike Kaganski
Modified: 2022-10-17 17:29 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2022-07-25 09:41:49 UTC
Sub crash
  stream = CreateUnoService("com.sun.star.io.TextInputStream")
  stream.available()
End Sub

This crashes the process, which is an unacceptable outcome (it should raise an exception, translated to Basic run-time error).

The code of OTextInputStream [1] does not check if its mxStream is valid before dereferencing.

The easy hack is to add the checking code, that would throw an appropriate runtime exception.

[1] https://opengrok.libreoffice.org/xref/core/io/source/TextInputStream/TextInputStream.cxx?r=ed9ff1a3#53
Comment 1 Rafael Lima 2022-07-25 17:24:20 UTC
Repro with

Version: 7.5.0.0.alpha0+ / LibreOffice Community
Build ID: 21a31eefab1401d288dbb8220f3df3365be9efaf
CPU threads: 16; OS: Linux 5.15; UI render: default; VCL: kf5 (cairo+xcb)
Locale: pt-BR (pt_BR.UTF-8); UI: en-US
Calc: threaded

LibreOffice crashes as reported by the OP. The interpreter should have treated this as a runtime exception and caught the error before crashing.