Fwd: New Defects reported by Coverity Scan for LyX

Thibaut Cuvelier dourouc05 at gmail.com
Thu Oct 26 01:44:35 UTC 2023


---------- Forwarded message ---------
From: Thibaut Cuvelier <tcuvelier at lyx.org>
Date: Thu, 26 Oct 2023, 03:35
Subject: Fwd: New Defects reported by Coverity Scan for LyX
To: LyX Developers <lyx-devel at lists.lyx.org>


Dear list,

I am attaching a patch that fixes two Coverity warnings. Could anyone
commit this to the Git repo (given I currently have no access to it)? As it
was generated with git format-patch, it should be easy to do while keeping
the commit message that explains the rationale behind the fix.

Thanks in advance!
Thibaut

---------- Forwarded message ---------
From: <scan-admin at coverity.com>
Date: Thu, 19 Oct 2023 at 22:54
Subject: New Defects reported by Coverity Scan for LyX
To: <dourouc05 at gmail.com>


Hi,

Please find the latest report on new defect(s) introduced to LyX found with
Coverity Scan.

2 new defect(s) introduced to LyX found with Coverity Scan.


New defect(s) Reported-by: Coverity Scan
Showing 2 of 2 defect(s)


** CID 403673:  Incorrect expression  (IDENTICAL_BRANCHES)
/home/lasgoutt/src/lyx/coverity/lyx/src/tex2lyx/text.cpp: 4351 in
lyx::parse_text(lyx::Parser &, std::basic_ostream<char,
std::char_traits<char>>&, unsigned int, bool, lyx::Context &, const
std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char>> &, const std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char>> &)()


________________________________________________________________________________________________________
*** CID 403673:  Incorrect expression  (IDENTICAL_BRANCHES)
/home/lasgoutt/src/lyx/coverity/lyx/src/tex2lyx/text.cpp: 4351 in
lyx::parse_text(lyx::Parser &, std::basic_ostream<char,
std::char_traits<char>>&, unsigned int, bool, lyx::Context &, const
std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char>> &, const std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char>> &)()
4345                            parse_text_snippet(p, os, FLAG_ITEM, outer,
context);
4346                            bool xcolorulem =
LaTeXPackages::isAvailable("ulem") &&
4347
LaTeXPackages::isAvailable("xcolor");
4348                            // No need to test for luatex, since luatex
comes in
4349                            // two flavours (dvi and pdf), like latex,
and those
4350                            // are detected by pdflatex.
>>>     CID 403673:  Incorrect expression  (IDENTICAL_BRANCHES)
>>>     The same code is executed regardless of whether "lyx::pdflatex ||
lyx::xetex" is true, because the 'then' and 'else' branches are identical.
Should one of the branches be modified, or the entire 'if' statement
replaced?
4351                            if (pdflatex || xetex) {
4352                                    if (xcolorulem) {
4353
preamble.registerAutomaticallyLoadedPackage("ulem");
4354
preamble.registerAutomaticallyLoadedPackage("xcolor");
4355                                    }
4356                            } else {

** CID 403672:  Error handling issues  (CHECKED_RETURN)
/home/lasgoutt/src/lyx/coverity/lyx/src/insets/InsetInfo.cpp: 1587 in
lyx::<unnamed>::xhtmlShortcutInfo(lyx::XMLStream &, const
lyx::InsetInfoParams &)()


________________________________________________________________________________________________________
*** CID 403672:  Error handling issues  (CHECKED_RETURN)
/home/lasgoutt/src/lyx/coverity/lyx/src/insets/InsetInfo.cpp: 1587 in
lyx::<unnamed>::xhtmlShortcutInfo(lyx::XMLStream &, const
lyx::InsetInfoParams &)()
1581            string const lcode = params.lang->code();
1582            docstring trans;
1583            for (size_t i = 0; i < sequence.length(); ++i) {
1584                char_type const c = sequence[i];
1585                    const auto keyMapping = keyToString.find(c);
1586                    if (keyMapping != keyToString.end()) {
>>>     CID 403672:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "translateString" without checking return value (as is done
elsewhere 15 out of 18 times).
1587
translateString(from_ascii(keyMapping->second), trans, lcode);
1588                            xs << trans;
1589                    } else {
1590                            xs << c;
1591                    }
1592


________________________________________________________________________________________________________
To view the defects in Coverity Scan visit,
https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50yoTScfh6B8koVa-2BsXrqsH2r7zUmO9t1iEi-2FFYNyEDxxSQ-3D-3DsI5y_EaoV9iDrwluI0GGUrbM7yWAc9ILy2qIm0bzgdOF2o6OvKSta0m1PyhfKtFZpqs5rxkZ0WyT4tDIrKOVdRzCQUcgJBhEZL-2FoBWogZGuZsQC-2Bq0AbrFZDRbh6FzKvH7PuKIgIPnV5R1jUXR4Pa7I5qkEG-2FqT5uQIViXTNlHVpGxd3kG3fmlowNDXT2qSzXiuqPTFSxrInHD6j7Cz-2FWufFoDw-3D-3D

  To manage Coverity Scan email notifications for "dourouc05 at gmail.com",
click
https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50yped04pjJnmXOsUBtKYNIXxxF-2FO44sWaogU6jGZMVL91U2CAiKpstwf-2F8GS1cLm5bQFa2vNdaMB9I0sFa-2FifkyGPDQ9lPJpxrLzv5JkQQq3cko-2Bs4SC3hxsw-2BPRRBy49SI-3D7CxO_EaoV9iDrwluI0GGUrbM7yWAc9ILy2qIm0bzgdOF2o6OvKSta0m1PyhfKtFZpqs5rOv1mjtxIcNA1-2BLpFky2OOXQ6ExpkSk52MJq4xUJIfv7mlJOCFNj0N3zW2gF-2FyB4sS4owJvxQWsBtMLx1FOu06Mn9mxTRKUrRjoIP3llSsiz-2FzmYV8YrnO8QCCDcbvrPjEdlzbTKFt5-2Fbqvb9L58JtQ-3D-3D
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20231026/8fe295f9/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-XHTML-fix-Coverity-warnings-about-return-values-of-t.patch
Type: application/x-patch
Size: 1629 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20231026/8fe295f9/attachment-0001.bin>


More information about the lyx-devel mailing list