summaryrefslogtreecommitdiffstats
path: root/tools/h5dump
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2011-04-25 16:38:56 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2011-04-25 16:38:56 (GMT)
commit0efc913a6799080c5399a761f603cd80b93e71f0 (patch)
tree81dcd8d246fb4207a9c49e1904ce91259ec4c919 /tools/h5dump
parentfbd98fe9fb6566e00b2401466b3584f325494cfc (diff)
downloadhdf5-0efc913a6799080c5399a761f603cd80b93e71f0.zip
hdf5-0efc913a6799080c5399a761f603cd80b93e71f0.tar.gz
hdf5-0efc913a6799080c5399a761f603cd80b93e71f0.tar.bz2
[svn-r20624] Albert's test on bp reveals that the dumper had assertion failure when it tried to display empty attribute data. I added
a check for empty attribute in h5dump.c. I also added a check for empty dataset in tools/lib/h5tools.c. Tested on jam, linew, and amani.
Diffstat (limited to 'tools/h5dump')
-rw-r--r--tools/h5dump/h5dump.c76
1 files changed, 40 insertions, 36 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 1b140ac..6ac32f3 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -2495,7 +2495,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index)
{
h5tool_format_t *outputformat = &dataformat;
int status = -1;
- void *buf;
+ void *buf = NULL;
hid_t space, type, p_type;
H5S_class_t space_type;
int ndims, i;
@@ -2645,45 +2645,49 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index)
alloc_size = nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type));
assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
- buf = malloc((size_t)alloc_size);
- assert(buf);
-
- if (H5Aread(obj_id, p_type, buf) >= 0)
- if (display_char && H5Tget_size(type) == 1 && H5Tget_class(type) == H5T_INTEGER) {
- /*
- * Print 1-byte integer data as an ASCII character string
- * instead of integers if the `-r' or `--string' command-line
- * option was given.
- *
- * We don't want to modify the global dataformat, so make a
- * copy of it instead.
- */
- string_dataformat = *outputformat;
- string_dataformat.idx_fmt = " ";
- string_dataformat.line_multi_new = 1;
- string_dataformat.line_1st = " %s\"";
- string_dataformat.line_pre = " %s";
- string_dataformat.line_cont = " %s";
- string_dataformat.str_repeat = 8;
- string_dataformat.ascii = TRUE;
- string_dataformat.elmt_suf1 = "";
- string_dataformat.elmt_suf2 = "";
- string_dataformat.line_indent = "";
- strcpy(string_prefix, string_dataformat.line_pre);
- strcat(string_prefix, "\"");
- string_dataformat.line_pre = string_prefix;
- string_dataformat.line_suf = "\"";
- outputformat = &string_dataformat;
- }
+ if(alloc_size) {
+ buf = malloc((size_t)alloc_size);
+ assert(buf);
+
+ if (H5Aread(obj_id, p_type, buf) >= 0)
+ if (display_char && H5Tget_size(type) == 1 && H5Tget_class(type) == H5T_INTEGER) {
+ /*
+ * Print 1-byte integer data as an ASCII character string
+ * instead of integers if the `-r' or `--string' command-line
+ * option was given.
+ *
+ * We don't want to modify the global dataformat, so make a
+ * copy of it instead.
+ */
+ string_dataformat = *outputformat;
+ string_dataformat.idx_fmt = " ";
+ string_dataformat.line_multi_new = 1;
+ string_dataformat.line_1st = " %s\"";
+ string_dataformat.line_pre = " %s";
+ string_dataformat.line_cont = " %s";
+ string_dataformat.str_repeat = 8;
+ string_dataformat.ascii = TRUE;
+ string_dataformat.elmt_suf1 = "";
+ string_dataformat.elmt_suf2 = "";
+ string_dataformat.line_indent = "";
+ strcpy(string_prefix, string_dataformat.line_pre);
+ strcat(string_prefix, "\"");
+ string_dataformat.line_pre = string_prefix;
+ string_dataformat.line_suf = "\"";
+ outputformat = &string_dataformat;
+ }
- status = h5tools_dump_mem(stdout, outputformat, obj_id, p_type,
+ status = h5tools_dump_mem(stdout, outputformat, obj_id, p_type,
space, buf, depth);
- /* Reclaim any VL memory, if necessary */
- if (vl_data)
- H5Dvlen_reclaim(p_type, space, H5P_DEFAULT, buf);
+ /* Reclaim any VL memory, if necessary */
+ if (vl_data)
+ H5Dvlen_reclaim(p_type, space, H5P_DEFAULT, buf);
+
+ free(buf);
+ } else
+ status = SUCCEED;
- free(buf);
H5Tclose(p_type);
H5Tclose(type);
}