for (n=2; (sai = sai->ai_next) != NULL; n++) {
/* EMPTY */ ;
}
- *sal = ch_malloc(n * sizeof(void *));
+ *sal = ch_calloc(n, sizeof(void *));
if (*sal == NULL) {
return -1;
}
inet_ntop( AF_INET, &((struct sockaddr_in *)*sal)->sin_addr,
addr, sizeof(addr) );
s = addr;
- port = ((struct sockaddr_in *)*sal) ->sin_port;
#else
- s = inet_ntoa( l.sl_addr.sin_addr );
- port = l.sl_addr.sin_port;
+ s = inet_ntoa( ((struct sockaddr_in *) *sal)->sin_addr );
#endif
+ port = ((struct sockaddr_in *)*sal) ->sin_port;
l.sl_name = ch_malloc( sizeof("IP=255.255.255.255:65535") );
sprintf( l.sl_name, "IP=%s:%d",
s != NULL ? s : "unknown" , port );
}
#endif /* LDAP_PF_LOCAL */
slapd_close( slap_listeners[l]->sl_sd );
- break;
}
+ if ( slap_listeners[l]->sl_url )
+ free ( slap_listeners[l]->sl_url );
+ if ( slap_listeners[l]->sl_name )
+ free ( slap_listeners[l]->sl_name );
+ free ( slap_listeners[l] );
}
+ free ( slap_listeners );
+ slap_listeners = NULL;
#ifdef NEW_LOGGING
LDAP_LOG(( "connection", LDAP_LEVEL_CRIT,