ensure Asterisk won't segfault during re-registration (issue #5011)
authorKevin P. Fleming <kpfleming@digium.com>
Thu, 25 Aug 2005 02:33:21 +0000 (02:33 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Thu, 25 Aug 2005 02:33:21 +0000 (02:33 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6402 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 1a047d5..f5e2cec 100755 (executable)
@@ -1017,7 +1017,7 @@ static int append_history(struct sip_pvt *p, char *event, char *data)
        struct sip_history *hist, *prev;
        char *c;
 
-       if (!recordhistory)
+       if (!recordhistory || !p)
                return 0;
        if(!(hist = malloc(sizeof(struct sip_history)))) {
                ast_log(LOG_WARNING, "Can't allocate memory for history");
@@ -4747,7 +4747,7 @@ static int sip_reregister(void *data)
        if (!r)
                return 0;
 
-       if (recordhistory) {
+       if (r->call && recordhistory) {
                char tmp[80];
                snprintf(tmp, sizeof(tmp), "Account: %s@%s", r->username, r->hostname);
                append_history(r->call, "RegistryRenew", tmp);
@@ -4759,7 +4759,7 @@ static int sip_reregister(void *data)
 
        r->expire = -1;
        __sip_do_register(r);
-       ASTOBJ_UNREF(r,sip_registry_destroy);
+       ASTOBJ_UNREF(r, sip_registry_destroy);
        return 0;
 }
 
@@ -4767,7 +4767,8 @@ static int sip_reregister(void *data)
 static int __sip_do_register(struct sip_registry *r)
 {
        int res;
-       res=transmit_register(r, SIP_REGISTER, NULL, NULL);
+
+       res = transmit_register(r, SIP_REGISTER, NULL, NULL);
        return res;
 }