diff options
Diffstat (limited to 'basic/source')
-rw-r--r-- | basic/source/runtime/methods.cxx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 8543c0817762..3214dd28602c 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -330,8 +330,15 @@ static void implChr( SbxArray& rPar, bool bChrW ) } else { - sal_Unicode aCh = static_cast<sal_Unicode>(pArg->GetUShort()); - aStr = OUString(aCh); + // Map negative 16-bit values to large positive ones, so that code like Chr(&H8000) + // still works after the fix for tdf#62326 changed those four-digit hex notations to + // produce negative values: + sal_Int32 aCh = pArg->GetLong(); + if (aCh < -0x8000 || aCh > 0xFFFF) { + StarBASIC::Error(ERRCODE_BASIC_MATH_OVERFLOW); + aCh = 0; + } + aStr = OUString(static_cast<sal_Unicode>(aCh)); } rPar.Get32(0)->PutString( aStr ); } |