ef117cad3a
rtl_[u]String_newConcat now checks allocation result to return early and avoid SIGSEGV. Other functions are not modified, to keep old behavior relying on allocation success and crashing early on OOM to avoid added overhead in performance-critical places. OUString operator+= now checks rtl_uString_newConcat result and throws std::bad_alloc on failure, to specifically address BASIC problem. It keeps strong exception guarantee of leaving this' state unaltered. Concatenation in BASIC now checks for bad string allocation (previously SIGSEGV was generated). Unit test included. Change-Id: I1513311d3d58eac43b2d2ec9a230e22dff0b4245 Reviewed-on: https://gerrit.libreoffice.org/37965 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Jenkins <ci@libreoffice.org>
22 lines
602 B
VB.net
22 lines
602 B
VB.net
Option Explicit
|
|
|
|
Function doUnitTest As Integer
|
|
' Trying to create too long string should generate proper BASIC overflow error.
|
|
' Longest possible string is 2147483638 wchar_t (2G - 10).
|
|
' This tries to create string with 2G wchar_t. If it does not overflow, test fails.
|
|
' If overflow is not safe, it segfaults.
|
|
On Error GoTo errorHandler
|
|
Dim s As String, i As Integer
|
|
s = "0"
|
|
For i=1 To 31
|
|
s = s & s
|
|
Next i
|
|
doUnitTest = 0
|
|
Exit Function
|
|
errorHandler:
|
|
If ( Err <> 6 ) Then
|
|
doUnitTest = 0
|
|
Else
|
|
doUnitTest = 1
|
|
Endif
|
|
End Function
|