ucb/source/ucp/gio/gio_content.cxx |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

New commits:
commit d2f1f5005e0df725d9f1830e278b06a151c860b6
Author:     Caolán McNamara <[email protected]>
AuthorDate: Tue Oct 19 09:28:00 2021 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Tue Oct 19 16:48:12 2021 +0200

    Related: tdf#145169 use of freed pointer in gio create folder
    
    and
    
    Related: tdf#145169 missing path separator in gio create folder
    
    Change-Id: I7fa98e05261b6c1ff7c053b5f563ea97bd67ed00
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123801
    Reviewed-by: Justin Luth <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Caolán McNamara <[email protected]>

diff --git a/ucb/source/ucp/gio/gio_content.cxx 
b/ucb/source/ucp/gio/gio_content.cxx
index 1e084d638126..1edca770b394 100644
--- a/ucb/source/ucp/gio/gio_content.cxx
+++ b/ucb/source/ucp/gio/gio_content.cxx
@@ -684,7 +684,7 @@ css::uno::Sequence< css::uno::Any > 
Content::setPropertyValues(
     aEvent.PropertyHandle = -1;
 
     sal_Int32 nChanged = 0, nTitlePos = -1;
-    const char *newName = nullptr;
+    OUString aNewTitle;
     css::uno::Sequence< css::beans::PropertyChangeEvent > aChanges(nCount);
 
     css::uno::Sequence< css::uno::Any > aRet( nCount );
@@ -704,7 +704,6 @@ css::uno::Sequence< css::uno::Any > 
Content::setPropertyValues(
         }
         else if ( rValue.Name == "Title" )
         {
-            OUString aNewTitle;
             if (!( rValue.Value >>= aNewTitle ))
             {
                 aRet[ n ] <<= css::beans::IllegalTypeException
@@ -723,7 +722,7 @@ css::uno::Sequence< css::uno::Any > 
Content::setPropertyValues(
             }
 
             OString sNewTitle = OUStringToOString(aNewTitle, 
RTL_TEXTENCODING_UTF8);
-            newName = sNewTitle.getStr();
+            const char *newName = sNewTitle.getStr();
             const char *oldName = g_file_info_get_name( pInfo);
 
             if (!newName || !oldName || strcmp(newName, oldName))
@@ -744,7 +743,6 @@ css::uno::Sequence< css::uno::Any > 
Content::setPropertyValues(
         {
             SAL_WARN("ucb.ucp.gio", "Unknown property " << rValue.Name);
             aRet[ n ] <<= getReadOnlyException( static_cast< cppu::OWeakObject 
* >(this) );
-            //TODO
         }
     }
 
@@ -764,8 +762,11 @@ css::uno::Sequence< css::uno::Any > 
Content::setPropertyValues(
         {
             if (nTitlePos > -1)
             {
-                OUString aNewURL = getParentURL() +
-                    OUString( newName, strlen(newName), RTL_TEXTENCODING_UTF8 
);
+                OUString aNewURL = getParentURL();
+                if (!aNewURL.isEmpty() && aNewURL[aNewURL.getLength() - 1] != 
'/')
+                    aNewURL += "/";
+                aNewURL += aNewTitle;
+
                 css::uno::Reference< css::ucb::XContentIdentifier > xNewId
                     = new ::ucbhelper::ContentIdentifier( aNewURL );
 

Reply via email to