summaryrefslogtreecommitdiffstats
path: root/tools/src/h5dump
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2020-04-27 15:50:27 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2020-04-27 15:50:27 (GMT)
commitc03ee563f46013d22f36a1895664a9ba876558e9 (patch)
tree147990d80682a724e79481a9ddef1df3f157c259 /tools/src/h5dump
parentde3bfa697a9fcb4fabf755b2bda7fa553abfcebb (diff)
downloadhdf5-c03ee563f46013d22f36a1895664a9ba876558e9.zip
hdf5-c03ee563f46013d22f36a1895664a9ba876558e9.tar.gz
hdf5-c03ee563f46013d22f36a1895664a9ba876558e9.tar.bz2
Further updates to the tools warnings fixes from code review.
Diffstat (limited to 'tools/src/h5dump')
-rw-r--r--tools/src/h5dump/h5dump_xml.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c
index bd822bc..07cff6a 100644
--- a/tools/src/h5dump/h5dump_xml.c
+++ b/tools/src/h5dump/h5dump_xml.c
@@ -738,9 +738,9 @@ 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)
@@ -793,18 +793,22 @@ xml_escape_the_string(const char *str, int slen)
}
else if (*cp == '\'') {
HDstrncpy(ncp, apos, ncp_len);
+ ncp[ncp_len - 1] = '\0';
esc_len = HDstrlen(apos);
}
else if (*cp == '<') {
HDstrncpy(ncp, lt, ncp_len);
+ ncp[ncp_len - 1] = '\0';
esc_len = HDstrlen(lt);
}
else if (*cp == '>') {
HDstrncpy(ncp, gt, ncp_len);
+ ncp[ncp_len - 1] = '\0';
esc_len = HDstrlen(gt);
}
else if (*cp == '&') {
HDstrncpy(ncp, amp, ncp_len);
+ ncp[ncp_len - 1] = '\0';
esc_len = HDstrlen(amp);
}
else {