Commit 583ed215 authored by Pekka Pessi's avatar Pekka Pessi

Fixed bugs with auto allocation.

In C89 and later, the automatic variable may go away when block is exited.
The buggy code relied on behaviour of K&R C, where automatic variables are
reclaimed when function returns.

darcs-hash:20051213130642-65a35-6908b78907e2a7b81e71e1196669ddca4def2ef1.gz
parent 31f2c5f8
......@@ -27,7 +27,6 @@
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
*
* @date Created: Wed Feb 14 18:32:58 2001 ppessi
* @date Last modified: Wed Jul 20 20:35:27 2005 kaiv
*/
#include "config.h"
......@@ -470,6 +469,8 @@ int handle_notify(nea_t *nea,
sip_t const *sip)
{
sip_subscription_state_t *ss = sip->sip_subscription_state;
sip_subscription_state_t ss0[1];
char expires[32];
if (nea->nea_strict_3265) {
char const *phrase = NULL;
......@@ -491,9 +492,7 @@ int handle_notify(nea_t *nea,
if (ss == NULL) {
/* Do some compatibility stuff here */
sip_subscription_state_t ss0[1];
unsigned long delta = 3600;
char expires[32];
sip_subscription_state_init(ss = ss0);
......
......@@ -1614,6 +1614,7 @@ int nea_sub_process_subscribe(nea_sub_t *s,
sip_event_t const *o;
sip_accept_t const *ac = NULL, *accept = NULL;
sip_accept_t *a0 = NULL, *a, *a_next, **aa;
sip_accept_t accept_default[1];
unsigned proposed_throttle;
char const *type, *throttle;
int once, what, supported_eventlist, require_eventlist;
......@@ -1752,11 +1753,9 @@ int nea_sub_process_subscribe(nea_sub_t *s,
accept = sip->sip_accept;
else if (evv && evv->evv_content_type) {
/* Generate accept header from event view specified by application */
sip_accept_t a0[1];
sip_accept_init(a0);
a0->ac_type = evv->evv_content_type->c_type;
a0->ac_subtype = evv->evv_content_type->c_subtype;
sip_accept_init(accept_default);
accept_default->ac_type = evv->evv_content_type->c_type;
accept_default->ac_subtype = evv->evv_content_type->c_subtype;
accept = a0;
}
......
......@@ -2859,6 +2859,7 @@ int nta_msg_request_complete(msg_t *msg,
sip_t *sip = sip_object(msg);
sip_cseq_t *cseq;
uint32_t seq;
url_t reg_url[1];
if (!leg || !msg)
return -1;
......@@ -2921,7 +2922,6 @@ int nta_msg_request_complete(msg_t *msg,
request_uri = (url_string_t *)sip->sip_to->a_url;
else {
/* Remove user part from REGISTER requests */
url_t reg_url[1];
*reg_url = *sip->sip_to->a_url;
reg_url->url_user = reg_url->url_password = NULL;
request_uri = (url_string_t *)reg_url;
......@@ -9312,13 +9312,10 @@ nta_outgoing_t *nta_outgoing_prack(nta_leg_t *leg,
return NULL;
if (!leg->leg_route) {
sip_route_t r0[1];
sip_route_init(r0);
/* Insert contact */
/* Insert contact into route */
if (resp->sip_contact) {
*r0->r_url = *resp->sip_contact->m_url;
sip_route_t r0[1];
sip_route_init(r0)->r_url[0] = resp->sip_contact->m_url[0];
route = sip_route_dup(home, r0);
}
......
......@@ -6286,6 +6286,8 @@ static int process_notify(nua_t *nua,
nua_dialog_state_t *ds = nh->nh_ds;
nua_dialog_usage_t *du;
sip_subscription_state_t *subs = sip ? sip->sip_subscription_state : NULL;
sip_subscription_state_t ss0[1];
char expires[32];
sip_contact_t *m = NULL, m0[1];
int retry = -1;
char const *what = NULL, *why = NULL;
......@@ -6319,9 +6321,7 @@ static int process_notify(nua_t *nua,
if (subs == NULL) {
/* Do some compatibility stuff here */
sip_subscription_state_t ss0[1];
unsigned long delta = 3600;
char expires[32];
sip_subscription_state_init(subs = ss0);
......@@ -6527,7 +6527,7 @@ int process_refer(nua_t *nua,
{
nua_dialog_usage_t *du = NULL;
sip_event_t *event;
sip_referred_by_t *by = NULL;
sip_referred_by_t *by = NULL, default_by[1];
msg_t *response;
int created = 0;
......@@ -6555,14 +6555,12 @@ int process_refer(nua_t *nua,
dialog_uas_route(nh, sip, 1); /* Set route and tags */
if (!sip->sip_referred_by) {
sip_referred_by_t b[1];
sip_from_t *a = sip->sip_from;
sip_referred_by_init(b);
sip_referred_by_init(by = default_by);
*b->b_url = *a->a_url;
b->b_display = a->a_display;
by = b;
*by->b_url = *a->a_url;
by->b_display = a->a_display;
}
response = nh_make_response(nua, nh, irq,
......
......@@ -905,6 +905,7 @@ int localinfo0(su_localinfo_t const hints[1], su_localinfo_t **rresult)
for (iaa = iaa0; iaa; iaa = iaa->Next) {
IP_ADAPTER_UNICAST_ADDRESS *ua;
IP_ADAPTER_UNICAST_ADDRESS lua[1];
int if_index = iaa->IfIndex;
int ifnamelen = 0;
char ifname[16];
......@@ -915,10 +916,9 @@ int localinfo0(su_localinfo_t const hints[1], su_localinfo_t **rresult)
su_sockaddr_t su2[1];
int scope, flags = 0, gni_flags = 0;
/* Fix bug: IP4 interface is not included... */
if (ua == NULL) {
/* There is no loopback interface in windows */
if (!loopback_seen && iaa->Next == NULL) {
IP_ADAPTER_UNICAST_ADDRESS lua[1];
struct sockaddr_in loopback_sin = { AF_INET, 0, {{ 127, 0, 0, 1 }}};
lua->Address.lpSockaddr = (struct sockaddr *)&loopback_sin;
......
......@@ -4357,6 +4357,9 @@ int tport_vsend_iovec(tport_t const *self, msg_t *msg,
{
su_sockaddr_t *su;
int sulen;
#if SU_HAVE_IN6 && defined(IN6_INADDR_TO_V4MAPPED)
su_sockaddr_t su0[1];
#endif
if (tport_is_connection_oriented(self)) {
#if __sun__ /* XXX - there must be better way... */
......@@ -4371,8 +4374,6 @@ int tport_vsend_iovec(tport_t const *self, msg_t *msg,
#if SU_HAVE_IN6 && defined(IN6_INADDR_TO_V4MAPPED)
if (su->su_family == AF_INET && self->tp_pri->pri_family == AF_INET6) {
su_sockaddr_t su0[1];
memset(su0, 0, sizeof su0);
su0->su_family = self->tp_pri->pri_family;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment