[poppler] glib/poppler-document.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Mar 8 13:41:54 UTC 2022


 glib/poppler-document.cc |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit a16189a8ba5c86389acf41822b78a569d5f666d9
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Mar 8 14:29:04 2022 +0100

    glib: Fix returning c_str() of temporal strings
    
    They go out of scope as soon as the function returns

diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc
index 9089023c..540e81a6 100644
--- a/glib/poppler-document.cc
+++ b/glib/poppler-document.cc
@@ -2785,7 +2785,7 @@ const char *poppler_fonts_iter_get_full_name(PopplerFontsIter *iter)
 
     info = iter->items[iter->index];
 
-    std::optional<std::string> name = info->getName();
+    const std::optional<std::string> &name = info->getName();
     if (name) {
         return name->c_str();
     } else {
@@ -2837,7 +2837,7 @@ const char *poppler_fonts_iter_get_substitute_name(PopplerFontsIter *iter)
 
     info = iter->items[iter->index];
 
-    std::optional<std::string> name = info->getSubstituteName();
+    const std::optional<std::string> &name = info->getSubstituteName();
     if (name) {
         return name->c_str();
     } else {
@@ -2860,7 +2860,7 @@ const char *poppler_fonts_iter_get_file_name(PopplerFontsIter *iter)
 
     info = iter->items[iter->index];
 
-    std::optional<std::string> file = info->getFile();
+    const std::optional<std::string> &file = info->getFile();
     if (file) {
         return file->c_str();
     } else {


More information about the poppler mailing list