summaryrefslogtreecommitdiff
path: root/sc/source/ui/view
diff options
context:
space:
mode:
authorHossein <hossein@libreoffice.org>2022-11-13 00:57:22 +0100
committerخالد حسني <khaled@aliftype.com>2022-11-14 12:08:08 +0100
commit2d7db6981e5087507c02bde6c0841c388cfaad0f (patch)
tree9ffd2d40384611c9207d39fa3a6c65001f739aad /sc/source/ui/view
parent9e134c17400f5c19f3dc2b93b1a76b3f3e56503d (diff)
tdf#152012 Fix assert fail on opening date picker
This patch fixes tdf#152012 which caused an assertion failure on opening date picker field in a DOCX file The assertion was: include/o3tl/span.hxx:83: constexpr o3tl::span<T>::value_type& o3tl:: span<T>::operator[](o3tl::span<T>::size_type) const [with T = const int; o3tl::span<T>::reference = const int&; o3tl::span<T>::size_type = long unsigned int]: Assertion `pos < size()' failed. And the backtrace was: 1 __pthread_kill_implementation pthread_kill.c:44 2 __pthread_kill_internal pthread_kill.c:78 3 __GI___pthread_kill pthread_kill.c:89 4 __GI_raise raise.c:26 5 __GI_abort abort.c:79 6 __assert_fail_base assert.c:92 7 __GI___assert_fail assert.c:101 8 o3tl::span<int const>::operator[] span.hxx:83 9 OutputDevice::ImplLayout text.cxx:1396 10 OutputDevice::DrawTextArray text.cxx:948 11 Calendar::ImplDraw calendar.cxx:71 12 Calendar::Paint calendar.cxx:1133 The problem was caused by an out of bound access to a vector of integers which was created for rendering calendar header consisting of the first letters of 7 days of week, when you clicked on the down arrow on the date field. The function OutputDevice::DrawTextArray() takes an 'rStr' string to draw, and 'pDXAry' array for the exact position of the the individual characters. It also takes 'nIndex' as the first index, and 'nLen' as the length of the array. 'nLen' has the default value of -1. In this case, the length is calculated from the size of the string passed to the function. This works well if the one who uses the function makes sure that the size of the array and the length of string are equal. Previously, for the 7 days of the week, a 7 letter string "smtwtfs" (depending on the week start day this can be different, but length is always 7) was sent to this method without providing the length, thus the string length: 7 was used. In this case, positions of the letters were calculated and used from other array named mnDayOfWeekAry[7]. mnDayOfWeekAry[k+1] was used as the position of letter k (k=0..5). In this case, there was 7 letters for 7 days, and only 6 positions provided by the array. This caused assertion failure in span.hxx:83 when trying to accesss mnDayOfWeekAry[7] via o3tl::span<T>::operator[]. Value of mnDayOfWeekAry[0] was used in other calculations, therefore to fix this problem, mnDayOfWeekAry was extended from 7 to 8, and the last position was set to the end of drawing rectangle. The other thing that is done in this patch to avoid this problem in the future is removing the default value from the function prototype, so that the use should always be done by providing the length of array and starting index. After removing these defaults, it became necessary to provide empty arrays for 'pKashidaAry' which provides the kashida positions, if needed. With this fix in place, the assertion failure no longer happens. A UI test is added to make sure the crash will not happen again. The test can be run by invoking: cd sw && make -srj1 UITest_writer_tests5 \ UITEST_TEST_NAME="DateFormFieldPropertiesDialog.dateFormFieldDialog.test_date_picker_drop_down" \ SAL_USE_VCLPLUGIN=gen Change-Id: I347afb358fbc4956524f7f0a0abc3a221bf42992 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142642 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
Diffstat (limited to 'sc/source/ui/view')
-rw-r--r--sc/source/ui/view/output2.cxx2
1 files changed, 1 insertions, 1 deletions
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 07f9f750ffe0..28d448fc69b9 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -2111,7 +2111,7 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co
}
if (bPaint)
- mpDev->DrawTextArray(aDrawTextPos, aShort, aDX);
+ mpDev->DrawTextArray(aDrawTextPos, aShort, aDX, {}, 0, nLen);
}
else
{