diff -Naur libreoffice-25.8.2.2.orig/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx libreoffice-25.8.2.2/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx
--- libreoffice-25.8.2.2.orig/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx	2025-10-01 07:38:12.000000000 -0400
+++ libreoffice-25.8.2.2/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx	2025-10-10 17:00:47.277183248 -0400
@@ -201,24 +201,23 @@
                 // Try opening the document with any password we have
                 {
                     // PDFDoc takes over ownership for all strings below
-                    GooString* pFileName = new GooString(myStringToStdString(argv[1]));
 
                     // check for password string(s)
-                    GooString* pOwnerPasswordStr(aPwBuf[0] != 0
-                                                 ? new GooString(aPwBuf)
+                    std::optional<GooString> pOwnerPasswordStr(aPwBuf[0] != 0
+                                                 ? aPwBuf
                                                  : (ownerPassword
-                                                    ? new GooString(myStringToStdString(ownerPassword))
+                                                    ? myStringToStdString(ownerPassword)
                                                     : nullptr));
-                    GooString* pUserPasswordStr(aPwBuf[0] != 0
-                                                ? new GooString(aPwBuf)
+                    std::optional<GooString> pUserPasswordStr(aPwBuf[0] != 0
+                                                ? aPwBuf
                                                 : (userPassword
-                                                  ? new GooString(myStringToStdString(userPassword))
+                                                  ? myStringToStdString(userPassword)
                                                   : nullptr));
 #if POPPLER_CHECK_VERSION(22, 6, 0)
                     pDocUnique = std::unique_ptr<PDFDoc>(
-                        new PDFDoc(std::make_unique<GooString>(pFileName),
-                                   std::optional<GooString>(pOwnerPasswordStr),
-                                   std::optional<GooString>(pUserPasswordStr)));
+                        new PDFDoc(std::make_unique<GooString>(GooString(myStringToStdString(argv[1]))),
+                                   pOwnerPasswordStr,
+                                   pUserPasswordStr));
 #else
                     pDocUnique = std::unique_ptr<PDFDoc>(
                         new PDFDoc(pFileName, pOwnerPasswordStr, pUserPasswordStr));
