From: Julius Enarusai Date: Fri, 8 Nov 2002 17:13:20 +0000 (+0000) Subject: Converted ch_malloc, ch_calloc and ch_realloc calls to SLAP_MALLOC, X-Git-Tag: NO_SLAP_OP_BLOCKS~815 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6e9c21cff8fc740dc6ed21c6f64d9a8899a33401;p=openldap Converted ch_malloc, ch_calloc and ch_realloc calls to SLAP_MALLOC, SLAP_CALLOC and SLAP_REALLOC respectively. --- diff --git a/servers/slapd/result.c b/servers/slapd/result.c index e6f727b5e6..4cfd8f1e2b 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -38,7 +38,16 @@ static char *v2ref( BerVarray ref, const char *text ) } } - v2 = ch_malloc( len+i+sizeof("Referral:") ); + v2 = SLAP_MALLOC( len+i+sizeof("Referral:") ); + if( v2 == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, ERR, "v2ref: SLAP_MALLOC failed", 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, "v2ref: SLAP_MALLOC failed", 0, 0, 0 ); +#endif + return NULL; + } + if( text != NULL ) { strcpy(v2, text); if( i ) { @@ -49,7 +58,15 @@ static char *v2ref( BerVarray ref, const char *text ) len += sizeof("Referral:"); for( i=0; ref[i].bv_val != NULL; i++ ) { - v2 = ch_realloc( v2, len + ref[i].bv_len + 1 ); + v2 = SLAP_REALLOC( v2, len + ref[i].bv_len + 1 ); + if( v2 == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, ERR, "v2ref: SLAP_MALLOC failed", 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, "v2ref: SLAP_MALLOC failed", 0, 0, 0 ); +#endif + return NULL; + } v2[len-1] = '\n'; AC_MEMCPY(&v2[len], ref[i].bv_val, ref[i].bv_len ); len += ref[i].bv_len; @@ -772,7 +789,23 @@ send_search_entry( size = i * sizeof(char *) + k; if ( size > 0 ) { char *a_flags; - e_flags = ch_calloc ( 1, i * sizeof(char *) + k ); + e_flags = SLAP_CALLOC ( 1, i * sizeof(char *) + k ); + if( e_flags == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, ERR, + "send_search_entry: conn %lu SLAP_CALLOC failed\n", + conn ? conn->c_connid : 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, + "send_search_entry: SLAP_CALLOC failed\n", 0, 0, 0 ); +#endif + ber_free( ber, 1 ); + + send_ldap_result( conn, op, LDAP_OTHER, + NULL, "memory error", + NULL, NULL ); + goto error_return; + } a_flags = (char *)(e_flags + i); memset( a_flags, 0, k ); for ( a = e->e_attrs, i=0; a != NULL; a = a->a_next, i++ ) { @@ -935,7 +968,7 @@ send_search_entry( * Reuse previous memory - we likely need less space * for operational attributes */ - tmp = ch_realloc ( e_flags, i * sizeof(char *) + k ); + tmp = SLAP_REALLOC ( e_flags, i * sizeof(char *) + k ); if ( tmp == NULL ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, ERR, diff --git a/servers/slapd/root_dse.c b/servers/slapd/root_dse.c index 6225622ab1..34f2977445 100644 --- a/servers/slapd/root_dse.c +++ b/servers/slapd/root_dse.c @@ -64,7 +64,18 @@ root_dse_info( vals[1].bv_val = NULL; - e = (Entry *) ch_calloc( 1, sizeof(Entry) ); + e = (Entry *) SLAP_CALLOC( 1, sizeof(Entry) ); + + if( e == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, ERR, + "root_dse_info: SLAP_CALLOC failed", 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, + "root_dse_info: SLAP_CALLOC failed", 0, 0, 0 ); +#endif + return LDAP_OTHER; + } e->e_attrs = NULL; e->e_name.bv_val = ch_strdup( LDAP_ROOT_DSE ); @@ -193,7 +204,17 @@ int read_root_dse_file( const char *fname ) return EXIT_FAILURE; } - usr_attr = (Entry *) ch_calloc( 1, sizeof(Entry) ); + usr_attr = (Entry *) SLAP_CALLOC( 1, sizeof(Entry) ); + if( usr_attr == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, ERR, + "read_root_dse_file: SLAP_CALLOC failed", 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, + "read_root_dse_file: SLAP_CALLOC failed", 0, 0, 0 ); +#endif + return LDAP_OTHER; + } usr_attr->e_attrs = NULL; while( ldif_read_record( fp, &lineno, &buf, &lmax ) ) {