@@ -1889,8 +1889,9 @@ H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type)
18891889
18901890 input_len = strlen (text );
18911891 myinput = strdup (text );
1892- if (!myinput )
1893- goto out ;
1892+ if (!myinput ) {
1893+ H5Epush_ret (__func__ , H5E_ERR_CLS , H5E_RESOURCE , H5E_NOSPACE , "memory allocation failed" , -1 );
1894+ }
18941895
18951896 if ((type_id = H5LTyyparse ()) < 0 ) {
18961897 free (myinput );
@@ -2189,7 +2190,7 @@ H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len)
21892190}
21902191
21912192/*-------------------------------------------------------------------------
2192- * Function: H5LT_append_dtype_super_text
2193+ * Function: append_dtype_super_text
21932194 *
21942195 * Purpose: Helper function to get super type text and append it to dt_str.
21952196 * This encapsulates the common pattern of: allocate buffer,
@@ -2200,21 +2201,23 @@ H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len)
22002201 *-------------------------------------------------------------------------
22012202 */
22022203static char *
2203- H5LT_append_dtype_super_text (hid_t super , char * dt_str , H5LT_lang_t lang , size_t * slen , bool no_user_buf )
2204+ append_dtype_super_text (hid_t super , char * dt_str , H5LT_lang_t lang , size_t * slen , bool no_user_buf )
22042205{
22052206 size_t super_len ;
22062207 char * stmp = NULL ;
22072208
22082209 /* Get required buffer size for super type text */
22092210 if (H5LTdtype_to_text (super , NULL , lang , & super_len ) < 0 )
22102211 return NULL ;
2212+ /* Treat zero-length result as failure rather than calling calloc(0,...) */
22112213 if (super_len == 0 )
22122214 return NULL ;
22132215
22142216 /* Allocate buffer for super type text */
22152217 stmp = (char * )calloc (super_len , sizeof (char ));
2216- if (!stmp )
2217- return NULL ;
2218+ if (!stmp ) {
2219+ H5Epush_ret (__func__ , H5E_ERR_CLS , H5E_RESOURCE , H5E_NOSPACE , "memory allocation failed" , NULL );
2220+ }
22182221
22192222 /* Convert super type to text */
22202223 if (H5LTdtype_to_text (super , stmp , lang , & super_len ) < 0 ) {
@@ -2634,7 +2637,7 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, bo
26342637 if ((super = H5Tget_super (dtype )) < 0 )
26352638 goto out ;
26362639 {
2637- char * tmp = H5LT_append_dtype_super_text (super , dt_str , lang , slen , no_user_buf );
2640+ char * tmp = append_dtype_super_text (super , dt_str , lang , slen , no_user_buf );
26382641 H5Tclose (super );
26392642 if (!tmp ) {
26402643 dt_str = NULL ; /* freed by callee's realloc_and_append on failure */
@@ -2673,7 +2676,7 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, bo
26732676 if ((super = H5Tget_super (dtype )) < 0 )
26742677 goto out ;
26752678 {
2676- char * tmp = H5LT_append_dtype_super_text (super , dt_str , lang , slen , no_user_buf );
2679+ char * tmp = append_dtype_super_text (super , dt_str , lang , slen , no_user_buf );
26772680 H5Tclose (super );
26782681 if (!tmp ) {
26792682 dt_str = NULL ; /* freed by callee's realloc_and_append on failure */
@@ -2727,7 +2730,7 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, bo
27272730 if ((super = H5Tget_super (dtype )) < 0 )
27282731 goto out ;
27292732 {
2730- char * tmp = H5LT_append_dtype_super_text (super , dt_str , lang , slen , no_user_buf );
2733+ char * tmp = append_dtype_super_text (super , dt_str , lang , slen , no_user_buf );
27312734 H5Tclose (super );
27322735 if (!tmp ) {
27332736 dt_str = NULL ; /* freed by callee's realloc_and_append on failure */
@@ -2832,7 +2835,7 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, bo
28322835 if ((super = H5Tget_super (dtype )) < 0 )
28332836 goto out ;
28342837 {
2835- char * tmp = H5LT_append_dtype_super_text (super , dt_str , lang , slen , no_user_buf );
2838+ char * tmp = append_dtype_super_text (super , dt_str , lang , slen , no_user_buf );
28362839 H5Tclose (super );
28372840 if (!tmp ) {
28382841 dt_str = NULL ; /* freed by callee's realloc_and_append on failure */
0 commit comments