diff --git a/Modules/Core/Metadata/include/otbMetadataSupplierInterface.h b/Modules/Core/Metadata/include/otbMetadataSupplierInterface.h
index 0e1aa8b4d7e353c3274cbd2d8f2c4b75786e2fba..3efc3ef8e5d9705716ec95b0d4145b657738e52e 100644
--- a/Modules/Core/Metadata/include/otbMetadataSupplierInterface.h
+++ b/Modules/Core/Metadata/include/otbMetadataSupplierInterface.h
@@ -77,7 +77,7 @@ public:
    * depends on the specific implementation. Returns empty string when path is not found,
    * and hasValue is set to False.
    * If band >= 0, the metadata value is looked in the specified band*/
-  virtual const std::string GetMetadataValue(const std::string path, bool& hasValue, int band=-1) const = 0;
+  virtual std::string GetMetadataValue(const std::string path, bool& hasValue, int band=-1) const = 0;
 
   bool HasValue(std::string path, int band=-1);
 
diff --git a/Modules/Core/Metadata/include/otbXMLMetadataSupplier.h b/Modules/Core/Metadata/include/otbXMLMetadataSupplier.h
index 2b78d3cc96018aaec8173d34ad0a3051b6d4b34b..0547b346f1417b20a8d5069cd1b5d2958f51b6d2 100644
--- a/Modules/Core/Metadata/include/otbXMLMetadataSupplier.h
+++ b/Modules/Core/Metadata/include/otbXMLMetadataSupplier.h
@@ -52,7 +52,7 @@ public:
    * @param band not used
    * @return The value corresponding to path. Empty string if not found.
    */
-  const std::string GetMetadataValue(const std::string path, bool& hasValue, int band=1) const override;
+  std::string GetMetadataValue(const std::string path, bool& hasValue, int band=1) const override;
 
   /**
    * @brief Get the first metadata value corresponding to a given path
@@ -61,7 +61,7 @@ public:
    * @param hasValue True if path is found
    * @return The value corresponding to path. Empty string if not found.
    */
-  const std::string GetFirstMetadataValue(const std::string paths, bool& hasValue) const;
+  std::string GetFirstMetadataValue(const std::string paths, bool& hasValue) const;
 
   /**
    * @brief Get the metadata value corresponding to a given path
diff --git a/Modules/Core/Metadata/src/otbXMLMetadataSupplier.cxx b/Modules/Core/Metadata/src/otbXMLMetadataSupplier.cxx
index 5470ac18394f5a4ceed3231114a8e492736c5601..0303154a1e201c495b32d334f51cee920b2b9c90 100644
--- a/Modules/Core/Metadata/src/otbXMLMetadataSupplier.cxx
+++ b/Modules/Core/Metadata/src/otbXMLMetadataSupplier.cxx
@@ -36,7 +36,7 @@ XMLMetadataSupplier::XMLMetadataSupplier(const std::string & fileName)
   CPLDestroyXMLNode(psNode);
 }
 
-const std::string XMLMetadataSupplier::GetMetadataValue(const std::string path, bool& hasValue, int band) const
+std::string XMLMetadataSupplier::GetMetadataValue(const std::string path, bool& hasValue, int band) const
 {
   const char * ret = CSLFetchNameValue(m_MetadataDic, path.c_str());
   if (ret)
@@ -49,7 +49,7 @@ const std::string XMLMetadataSupplier::GetMetadataValue(const std::string path,
   return std::string(ret);
 }
 
-const std::string XMLMetadataSupplier::GetFirstMetadataValue(const std::string path, bool& hasValue) const
+std::string XMLMetadataSupplier::GetFirstMetadataValue(const std::string path, bool& hasValue) const
 {
   // Search for the  first joker
   std::size_t found = path.find("_#");
@@ -74,9 +74,11 @@ const std::string XMLMetadataSupplier::GetFirstMetadataValue(const std::string p
   if ((values != nullptr) && (values[0] != nullptr))
   {
     hasValue = true;
-    std::string ret = std::string(values[0]);
+    std::string ret = values[0];
+    ret = ret.substr(ret.find('=') + 1);
+    CSLDestroy(values);
     // Return the value part
-    return ret.substr(ret.find('=') + 1);
+    return ret;
   }
   else
   {
diff --git a/Modules/IO/IOGDAL/include/otbGDALImageIO.h b/Modules/IO/IOGDAL/include/otbGDALImageIO.h
index ccbb07123a26e4d39cd057f9ee2d821453a94185..65a33def3e8d14c61e4a3ac71762505db46bd436 100644
--- a/Modules/IO/IOGDAL/include/otbGDALImageIO.h
+++ b/Modules/IO/IOGDAL/include/otbGDALImageIO.h
@@ -210,7 +210,7 @@ public:
   std::vector<std::string> GetResourceFiles() const override;
 
   /** Get metadata item in GDALDataset, domain can specified as "domain/key" */
-  const std::string GetMetadataValue(const std::string path, bool& hasValue, int band = -1) const override;
+  std::string GetMetadataValue(const std::string path, bool& hasValue, int band = -1) const override;
 
   /** Set metadata item in GDALDataset, domain can specified as prefix of the
    *  path, like "domain/key"*/
diff --git a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx
index 41505a81550bd6c834ba6ad2381db245919593e9..5dcb6b8ae1aa9123e4d9c0d94a5ed03479698643 100644
--- a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx
+++ b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx
@@ -1835,7 +1835,7 @@ std::vector<std::string> GDALImageIO::GetResourceFiles() const
   return result;
 }
 
-const std::string GDALImageIO::GetMetadataValue(const std::string path, bool& hasValue, int band) const
+std::string GDALImageIO::GetMetadataValue(const std::string path, bool& hasValue, int band) const
 {
   // detect namespace if any
   std::string domain("");