[Asterisk-Dev] possible bug in chan_sip

Paul Cadach paul at odt.east.telecom.kz
Thu Jan 13 08:13:50 MST 2005


Hello,

----- Original Message -----
From: "Maurizio Marini" <maumar at datalogica.com>
To: <asterisk-dev at lists.digium.com>
Sent: Thursday, January 13, 2005 8:52 PM
Subject: [Asterisk-Dev] possible bug in chan_sip


> in chan_sip.c line 1137:

[skip]

> should be (conceptualy):
>        while(tmp) {
>                 if (strcasecmp(tmp->name, "type")){
> tmp = tmp->next;
>                         continue;
> }
>
>                 if (!strcasecmp(tmp->value, "user")) {
>                         ast_destroy_realtime(var);
>                         return NULL;
>                 }
>
>                 tmp = tmp->next;
>         }

To eliminate such type of problems better is to use for() instead of while(). In current example usage of for()
expression will be (from line 1136):
  for(tmp = var; tmp; tmp = tmp->next) {
    if(strcasecmp(tmp->name, "type"))
      continue;
    if(!strcasecmp(tmp->value, "user")) {
      ast_destroy_realtime(var);
      return NULL;
    }
  }

More compact and readable IMHO.


WBR,
Paul.





More information about the asterisk-dev mailing list