5167
5167
 
                            old_size = memb_type->shared->size;
5168
5168
 
5169
5169
 
                            /* Mark the VL, compound, enum or array type */
5170
5170
 
                            if((changed = H5T_set_loc(memb_type,f,loc)) < 0)
5171
5171
 
                                HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location");
5172
5172
 
                            if(changed > 0)
5173
5173
 
                                ret_value = changed;
5174
5174
 
5175
5175
 
                            /* Check if the field changed size */
5176
5176
 
                            if(old_size != memb_type->shared->size) {
 
5177
+
 
5178
+
                                /* Fail if the old_size is zero */
 
5179
+
                                if (0 == old_size)
 
5180
+
                                    HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "old_size of zero would cause division by zero");
 
5181
+
5177
5182
 
                                /* Adjust the size of the member */
5178
5183
 
                                dt->shared->u.compnd.memb[i].size = (dt->shared->u.compnd.memb[i].size*memb_type->shared->size)/old_size;
5179
5184
 
5180
5185
 
                                /* Add that change to the accumulated size change */
5181
5186
 
                                accum_change += (ssize_t) (memb_type->shared->size - old_size);
5182
5187
 
                            } /* end if */
5183
5188
 
                        } /* end if */
5184
5189
 
                    } /* end for */
5185
5190
 
5186
5191
 
                    /* Range check against datatype size */