]> git.lyx.org Git - lyx.git/commitdiff
Fix potential crash with 32bit ucs4 codepoints
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 24 Nov 2022 00:18:21 +0000 (01:18 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 24 Nov 2022 00:18:54 +0000 (01:18 +0100)
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.

src/frontends/qt4/GuiFontMetrics.cpp

index 5bdbf187c7b4e4288ff94b38d8eb4ab7912f557f..b76538e60a1d43ac6f6320d52d568c9f64256a87 100644 (file)
 #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;