diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2020-04-27 15:50:27 (GMT) |
---|---|---|
committer | David Young <dyoung@hdfgroup.org> | 2020-05-20 14:37:20 (GMT) |
commit | 6eebd57742c5ba467565c22882ca5eb86cc0484b (patch) | |
tree | 03da99a0a5fbae7bfd5a070f443625a1c9ab784e /tools/src/h5dump/h5dump_xml.c | |
parent | e0d954f8455fed5ff46faf0194fc9cb5a9c8e359 (diff) | |
download | hdf5-6eebd57742c5ba467565c22882ca5eb86cc0484b.zip hdf5-6eebd57742c5ba467565c22882ca5eb86cc0484b.tar.gz hdf5-6eebd57742c5ba467565c22882ca5eb86cc0484b.tar.bz2 |
Further updates to the tools warnings fixes from code review.
Diffstat (limited to 'tools/src/h5dump/h5dump_xml.c')
-rw-r--r-- | tools/src/h5dump/h5dump_xml.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c index e6eb11a..b24c005 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 { |