Commit e205abf5 authored by Thomas Dennis's avatar Thomas Dennis
Browse files

Fix a missing NULL-terminator byte (reported by Valgrind)

parent 0797c6f8
......@@ -5,7 +5,7 @@
IMPORTANT: Unless noted otherwise, all text strings are stored in UTF-8 format.
Copyright (C) 2013-2014 Thomas Glyn Dennis.
Copyright (C) 2013-2015 Thomas Glyn Dennis.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
......@@ -156,7 +156,7 @@ int xmlSetText(xml_s *xml, const char *text)
} else { text = ""; }
if (xml->text) { free(xml->text); }
free(xml->text);
xml->text = (char*)malloc(strlen(text) + 1);
if (!xml->text) { return 1; }
strcpy(xml->text, text);
......@@ -551,7 +551,7 @@ static const char *xmlLoadNode(const char *text, xml_s *owner)
temp = (char*)malloc(len + 1);
if (!temp) { return NULL; }
strncpy(temp, text, len);
memcpy(temp, text, len); temp[len] = 0;
xmlSetText(node, temp);
......
......@@ -5,7 +5,7 @@
IMPORTANT: Unless noted otherwise, all text strings are stored in UTF-8 format.
Copyright (C) 2013-2014 Thomas Glyn Dennis.
Copyright (C) 2013-2015 Thomas Glyn Dennis.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
......@@ -48,6 +48,7 @@ typedef struct _xml_s
char *name; /**< @brief The name of this XML node/attribute. */
char *text; /**< @brief Text data (nodes) or attribute value. */
void *user; /**< @brief User-defined data; not used internally. */
struct _xml_s *attr; /**< @brief NODE ONLY: A linked list of attributes. */
struct _xml_s *node; /**< @brief NODE ONLY: A linked list of child nodes. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment