Am Freitag, dem 15.09.2023 um 10:45 +0200 schrieb Léo de Souza:
> 1. Create new document: File > New
> 2. Insert label: Insert > Label...
> 3. On a new line, switch layout to "Labeling" or "Description"
> 4. Insert cross-reference: Insert > Cross-Reference...
> 5. Try copying this cross-reference
> 
> Expected result (LyX 2.3.6): The cross-reference is copied to the
> clipboard.
> 
> Actual result (LyX 2.4.0 beta 5): LyX crashes with the message
> "SIGSEGV signal caught!"


Nullpointer issue due to local_font being non-defined in
InsetRef::xhtml().

The attached patch fixes this particular case, but there are many
similar uses in insets's xhtml methods which would need to be audited.

Thibaut, Riki?

-- 
Jürgen
diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp
index 746b9ea870..c7434a6a02 100644
--- a/src/insets/InsetRef.cpp
+++ b/src/insets/InsetRef.cpp
@@ -431,8 +431,11 @@ docstring InsetRef::xhtml(XMLStream & xs, OutputParams const & op) const
 	// appropriate sort of text here. But to do that, we need to associate
 	// some sort of counter with the label, and we don't have that yet.
 	docstring const attr = "href=\"#" + xml::cleanAttr(ref) + '"';
+	string const lang = (op.local_font != nullptr)
+			? op.local_font->language()->lang()
+			: buffer().params().language->lang();
 	xs << xml::StartTag("a", to_utf8(attr));
-	xs << displayString(ref, cmd, op.local_font->language()->lang());;
+	xs << displayString(ref, cmd, lang);
 	xs << xml::EndTag("a");
 	return docstring();
 }
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to