Fix potential crash with 32bit ucs4 codepoints

QChar codepoints are 16 bit, so it is not wise to pass blindly a
char_type value to the QChar constructor.

Use the already defined isSpace() helper tht takes care of this issue.

Related to #12519, which is only known to bite with Qt6 for now; this
bug is thus theoretical in 2.3.
This commit is contained in:
Jean-Marc Lasgouttes 2022-11-24 01:18:21 +01:00
parent 52ea367982
commit 08195c1d95

View File

@ -18,9 +18,10 @@
#include "Dimension.h"
#include "support/convert.h"
#include "support/debug.h"
#include "support/lassert.h"
#include "support/lyxlib.h"
#include "support/debug.h"
#include "support/textutils.h"
#define DISABLE_PMPROF
#include "support/pmprof.h"
@ -424,7 +425,7 @@ int GuiFontMetrics::countExpanders(docstring const & str) const
bool wasspace = false;
int nexp = 0;
for (char_type c : str)
if (c > 0x0d && QChar(c).isSpace()) {
if (c > 0x0d && isSpace(c)) {
if (!wasspace) {
++nexp;
wasspace = true;