summaryrefslogtreecommitdiff
path: root/unoxml
diff options
context:
space:
mode:
authorAndres Gomez <agomez@igalia.com>2013-09-16 15:56:53 +0300
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-09-20 08:54:08 +0000
commita30652bfef1ca8c8d6a20a01aabc700b92978fb3 (patch)
tree4de2a05613823df64ed7c905b685ea4bd6e5b1a7 /unoxml
parent290f03e8bb5071d7716fb6563e3274caa51102f0 (diff)
unoxml: avoid SIGSEV when xmlNsPtr prefix is NULL
When serializing a XDocument with "xmlns" elements, they usually come with a prefix like in xmlns:xlink="http://www.w3.org/1999/xlink". When the prefix doesn exist like in xmlns="", the prefix member of the xmlNsPtr structure is NULL and unsafe operations on it like "strlen" may cause a SIGSEV. Change-Id: Icdfcddeccb37c246a48aa1239b7f3c5b0b3727e3 Reviewed-on: https://gerrit.libreoffice.org/6003 Tested-by: Miklos Vajna <vmiklos@collabora.co.uk> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'unoxml')
-rw-r--r--unoxml/source/dom/element.cxx2
1 files changed, 1 insertions, 1 deletions
diff --git a/unoxml/source/dom/element.cxx b/unoxml/source/dom/element.cxx
index 87dba8a0a37c..e41420a2e7a9 100644
--- a/unoxml/source/dom/element.cxx
+++ b/unoxml/source/dom/element.cxx
@@ -55,7 +55,7 @@ namespace DOM
OUString type = "";
// add namespace definitions to attributes
for (xmlNsPtr pNs = m_aNodePtr->nsDef; pNs != 0; pNs = pNs->next) {
- const xmlChar *pPrefix = pNs->prefix;
+ const xmlChar *pPrefix = pNs->prefix ? pNs->prefix : (const xmlChar*)"";
OUString prefix(reinterpret_cast<const sal_Char*>(pPrefix),
strlen(reinterpret_cast<const char*>(pPrefix)),
RTL_TEXTENCODING_UTF8);