[LyX/master] Amend c734504d to fix a very bad nullptr dereferencing...

Thibaut Cuvelier tcuvelier at lyx.org
Sun Dec 26 00:55:47 UTC 2021


commit 4c27a7307e48533f1002d9c6fd1d7cacbe727383
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sun Dec 26 02:24:06 2021 +0100

    Amend c734504d to fix a very bad nullptr dereferencing...
---
 src/insets/InsetFloat.cpp |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp
index fc82d5c..3f4c0db 100644
--- a/src/insets/InsetFloat.cpp
+++ b/src/insets/InsetFloat.cpp
@@ -759,8 +759,7 @@ void docbookGenerateFillerTable(XMLStream & xs, BufferParams::TableOutput format
 
 
 void docbookNoSubfigures(XMLStream & xs, OutputParams const & runparams, const InsetCaption * caption,
-                         const InsetLabel * label, Floating const & ftype, const InsetFloat * thisFloat)
-{
+                         const InsetLabel * label, Floating const & ftype, const InsetFloat * thisFloat) {
 	// Ensure there is no label output, it is supposed to be handled as xml:id.
 	OutputParams rpNoLabel = runparams;
 	if (label)
@@ -775,15 +774,23 @@ void docbookNoSubfigures(XMLStream & xs, OutputParams const & runparams, const I
 
 	// Generate the contents of the float (to check for emptiness).
 	odocstringstream osFloatContent;
-	XMLStream xsFloatContent(osFloatContent);
-	thisFloat->InsetText::docbook(xsFloatContent, rpNoTitle);
-	bool hasFloat = !osFloatContent.str().empty();
+	bool hasFloat = false;
+
+	if (thisFloat) {
+		XMLStream xsFloatContent(osFloatContent);
+		thisFloat->InsetText::docbook(xsFloatContent, rpNoTitle);
+		hasFloat = !osFloatContent.str().empty();
+	}
 
 	// Do the same for the caption.
 	odocstringstream osCaptionContent;
-	XMLStream xsCaptionContent(osCaptionContent);
-	caption->getCaptionAsDocBook(xsCaptionContent, rpNoLabel);
-	bool hasCaption = !osCaptionContent.str().empty();
+	bool hasCaption = false;
+
+	if (caption != nullptr) {
+		XMLStream xsCaptionContent(osCaptionContent);
+		caption->getCaptionAsDocBook(xsCaptionContent, rpNoLabel);
+		hasCaption = !osCaptionContent.str().empty();
+	}
 
 	// Organisation: <float> <title if any/> <contents without title/> </float>.
 


More information about the lyx-cvs mailing list