diff options
Diffstat (limited to 'tools/src/h5dump')
-rw-r--r-- | tools/src/h5dump/h5dump_xml.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c index 4f58b73..07cff6a 100644 --- a/tools/src/h5dump/h5dump_xml.c +++ b/tools/src/h5dump/h5dump_xml.c @@ -732,15 +732,15 @@ xml_escape_the_name(const char *str) * Programmer: REMcG *------------------------------------------------------------------------- */ -static char * +static char * xml_escape_the_string(const char *str, int slen) { size_t extra; size_t len; size_t i; - const char *cp; - char *ncp; - char *rcp; + const char *cp = NULL; + char *ncp = NULL; + char *rcp = NULL; size_t ncp_len; if (!str) @@ -792,20 +792,24 @@ xml_escape_the_string(const char *str, int slen) esc_len = 1; } else if (*cp == '\'') { + HDstrncpy(ncp, apos, ncp_len); + ncp[ncp_len - 1] = '\0'; esc_len = HDstrlen(apos); - HDstrncpy(ncp, apos, esc_len); } else if (*cp == '<') { + HDstrncpy(ncp, lt, ncp_len); + ncp[ncp_len - 1] = '\0'; esc_len = HDstrlen(lt); - HDstrncpy(ncp, lt, esc_len); } else if (*cp == '>') { + HDstrncpy(ncp, gt, ncp_len); + ncp[ncp_len - 1] = '\0'; esc_len = HDstrlen(gt); - HDstrncpy(ncp, gt, esc_len); } else if (*cp == '&') { + HDstrncpy(ncp, amp, ncp_len); + ncp[ncp_len - 1] = '\0'; esc_len = HDstrlen(amp); - HDstrncpy(ncp, amp, esc_len); } else { *ncp = *cp; |