[svn-r5567] Purpose:

Bug fix (bug #777)

Description:
    Current code allows a compound datatype to be inserted into itself.

Solution:
    Check if the ID for the member is the same as the ID for the compound
    datatype and reject it if so.

Platforms tested:
    FreeBSD 4.5 (sleipnir)
This commit is contained in:
Quincey Koziol 2002-06-10 12:07:38 -05:00
parent 8bb2a0cfd8
commit 7a272fc660
2 changed files with 5 additions and 0 deletions

View File

@ -4315,6 +4315,8 @@ H5Tinsert(hid_t parent_id, const char *name, size_t offset, hid_t member_id)
H5TRACE4("e","iszi",parent_id,name,offset,member_id);
/* Check args */
if (parent_id==member_id)
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't insert compound datatype within itself");
if (H5I_DATATYPE != H5I_get_type(parent_id) ||
NULL == (parent = H5I_object(parent_id)) ||
H5T_COMPOUND != parent->type) {

View File

@ -397,6 +397,9 @@ test_compound_1(void)
/* Create the empty type */
if ((complex_id = H5Tcreate(H5T_COMPOUND, sizeof tmp))<0) goto error;
/* Attempt to add the new compound datatype as a field within itself */
if (H5Tinsert(complex_id, "compound", 0, complex_id)>=0) goto error;
/* Add a couple fields */
if (H5Tinsert(complex_id, "real", HOFFSET(complex_t, re),
H5T_NATIVE_DOUBLE)<0) goto error;