diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2018-10-19 19:45:04 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2018-10-19 19:45:04 (GMT) |
commit | cce1727525ac395e87c85e89d7a60ad4acd9a1cb (patch) | |
tree | 471b71ad9553d2561cedf859b8f9494317029e9f /tools/lib | |
parent | 6e846573146b714049c36b42da79f7f044190040 (diff) | |
download | hdf5-cce1727525ac395e87c85e89d7a60ad4acd9a1cb.zip hdf5-cce1727525ac395e87c85e89d7a60ad4acd9a1cb.tar.gz hdf5-cce1727525ac395e87c85e89d7a60ad4acd9a1cb.tar.bz2 |
TRILAB-81 check for func success before using value
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5tools_str.c | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 3d595ca..3e8f1fe 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -1045,43 +1045,47 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } else { - unsigned nmembs; - unsigned j; + int retvalue; - nmembs = (unsigned)H5Tget_nmembers(type); - h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); + retvalue = H5Tget_nmembers(type); + if (retvalue >= 0) { + unsigned j; + unsigned nmembs = (unsigned)retvalue; - ctx->indent_level++; + h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); - for(j = 0; j < nmembs; j++) { - if(j) - h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", "OPTIONAL_LINE_BREAK)); - else - h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); + ctx->indent_level++; - if(info->arr_linebreak) - h5tools_str_indent(str, info, ctx); + for(j = 0; j < nmembs; j++) { + if(j) + h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", "OPTIONAL_LINE_BREAK)); + else + h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); - /* The name */ - name = H5Tget_member_name(type, j); - h5tools_str_append(str, OPT(info->cmpd_name, ""), name); - H5free_memory(name); + if(info->arr_linebreak) + h5tools_str_indent(str, info, ctx); - /* The value */ - offset = H5Tget_member_offset(type, j); - memb = H5Tget_member_type(type, j); + /* The name */ + name = H5Tget_member_name(type, j); + h5tools_str_append(str, OPT(info->cmpd_name, ""), name); + H5free_memory(name); - h5tools_str_sprint(str, info, container, memb, cp_vp + offset, ctx); + /* The value */ + offset = H5Tget_member_offset(type, j); + memb = H5Tget_member_type(type, j); - H5Tclose(memb); - } - ctx->indent_level--; + h5tools_str_sprint(str, info, container, memb, cp_vp + offset, ctx); - if(info->arr_linebreak) { - h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); - h5tools_str_indent(str, info, ctx); + H5Tclose(memb); + } + ctx->indent_level--; + + if(info->arr_linebreak) { + h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); + h5tools_str_indent(str, info, ctx); + } + h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); } - h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); } break; |