[RFC][PATCH] Next results from code analyzer - null pointers

Richard Kimberly Heck rikiheck at lyx.org
Mon Feb 17 17:41:32 UTC 2020


On 2/17/20 9:28 AM, Stephan Witt wrote:
> Hi all,
>
> this is the next step in evaluating the code analyzing results.
>
> There are some potential null pointer problems found.
>
> Because I’m not able to preclude unwanted or side effects I present
> two patches here. Any comments or ok to apply?
index d5686f666d..a64d7472a7 100644
--- a/src/Converter.cpp
+++ b/src/Converter.cpp
@@ -586,7 +586,7 @@ Converters::RetVal Converters::convert(Buffer const
* buffer,

         if (conv.latex()) {
             // We are not importing, we have a buffer
-            LATTEST(buffer);
+            LASSERT(buffer, return FAILURE);
             run_latex = true;
             string command = conv.command();
             command = subst(command, token_from, "");
@@ -604,7 +604,7 @@ Converters::RetVal Converters::convert(Buffer const
* buffer,
         } else {
             if (conv.need_aux() && !run_latex) {
                 // We are not importing, we have a buffer
-                LATTEST(buffer);
+                LASSERT(buffer, return FAILURE);

These are ok.


                 string command;
                 switch (runparams.flavor) {
                 case OutputParams::DVILUATEX:
@@ -713,8 +713,8 @@ Converters::RetVal Converters::convert(Buffer const
* buffer,
                         " > " + quoteName(logfile);
                     res = one.startscript(starttype,
                         to_filesystem8bit(from_utf8(command2)),
-                        buffer->filePath(),
-                        buffer->layoutPos());
+                        buffer ? buffer->filePath() : string(),
+                        buffer ? buffer->layoutPos() : string());
                     if (res == Systemcall::KILLED) {
                         frontend::Alert::warning(
                             _("Converter killed"),
@@ -722,7 +722,7 @@ Converters::RetVal Converters::convert(Buffer const
* buffer,
                                 from_utf8(command)));
                         return KILLED;
                     }
-                    if (!scanLog(*buffer, command, makeAbsPath(logfile,
path), errorList))
+                    if (buffer && !scanLog(*buffer, command,
makeAbsPath(logfile, path), errorList))
                         return FAILURE;
                 }

             }

This seems fine, as well, and parallel to what's at line 685.

Riki





More information about the lyx-devel mailing list