From 4321262fc59588ac16088f7375587c62e9fb75a2 Mon Sep 17 00:00:00 2001 From: Adrien Prokopowicz Date: Sat, 27 Apr 2013 19:21:28 +0000 Subject: [PATCH] [GB.XML] * BUG: The XmlNode.Serialize() method does not crashes anymore if a null string is given. git-svn-id: svn://localhost/gambas/trunk@5622 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- gb.xml/src/CNode.cpp | 6 ++++++ gb.xml/src/textnode.cpp | 1 + 2 files changed, 7 insertions(+) diff --git a/gb.xml/src/CNode.cpp b/gb.xml/src/CNode.cpp index 568a5e96d..cedacb96e 100644 --- a/gb.xml/src/CNode.cpp +++ b/gb.xml/src/CNode.cpp @@ -291,6 +291,12 @@ END_METHOD BEGIN_METHOD(CNode_escapeContent, GB_STRING data) +if(!LENGTH(data)) +{ + GB.ReturnNull(); + return; +} + char *escapedData; size_t lenEscapedData; TextNode::escapeContent(STRING(data), LENGTH(data), escapedData, lenEscapedData); diff --git a/gb.xml/src/textnode.cpp b/gb.xml/src/textnode.cpp index 7093f20b2..5b8308887 100644 --- a/gb.xml/src/textnode.cpp +++ b/gb.xml/src/textnode.cpp @@ -58,6 +58,7 @@ void TextNode::escapeContent(const char *src, const size_t lenSrc, char *&dst, s { dst = (char*)src; lenDst = lenSrc; + if(!lenSrc || !src) return; char *posFound = strpbrk (dst, "<>&\""); while (posFound != 0) {