summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Baudin <xapantu@gmail.com>2025-01-17 14:33:13 +0100
committerAlbert Astals Cid <aacid@kde.org>2025-01-19 12:10:41 +0000
commit0d7c1e697358fd736bfb6051afaa9cb20691b8ae (patch)
tree4ccfc4f536658ddaeb0aacb5740794332136146b
parent74a33aed2b437817b4b1d63ed2bb77bf46e741af (diff)
glib: fix a crash when getting a font description for a free text annotation if it was not set
The font description of a free text annotation may be null, so this must be taken care of in the get_font_desc function.
-rw-r--r--glib/poppler-annot.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc
index 5a25707a..e0f3ecf4 100644
--- a/glib/poppler-annot.cc
+++ b/glib/poppler-annot.cc
@@ -2037,13 +2037,17 @@ void poppler_annot_free_text_set_font_desc(PopplerAnnotFreeText *poppler_annot,
*
* Gets the font description (i.e. font family name, style, weight, stretch and size).
*
- * Returns: (transfer full): a copy of the annotation font description
+ * Returns: (nullable) (transfer full): a copy of the annotation font description, or NULL if there is
+ * no font description set.
*
* Since: 24.12.0
**/
PopplerFontDescription *poppler_annot_free_text_get_font_desc(PopplerAnnotFreeText *poppler_annot)
{
- return poppler_font_description_copy(poppler_annot->font_desc);
+ if (poppler_annot->font_desc) {
+ return poppler_font_description_copy(poppler_annot->font_desc);
+ }
+ return nullptr;
}
/**