rem: }
add: }else orig_flag=0;
context: int parse_headers(struct sip_msg* msg, int flags, int next){	struct hdr_field* hf;	char* tmp;	char* rest;	char* end;	int orig_flag;	end=msg->buf+msg->len;	tmp=msg->unparsed;		if (next) {		orig_flag = msg->parsed_flag;		msg->parsed_flag &= ~flags;	}	DBG("parse_headers: flags=%d\n", flags);	while( tmp<end && (flags & msg->parsed_flag) != flags){		hf=pkg_malloc(sizeof(struct hdr_field));		if (hf==0){			ser_error=E_OUT_OF_MEM;			LOG(L_ERR, "ERROR:parse_headers: memory allocation error\n");			goto error;		}		memset(hf,0, sizeof(struct hdr_field));		hf->type=HDR_ERROR;		rest=get_hdr_field(tmp, msg->buf+msg->len, hf);		switch (hf->type){			case HDR_ERROR:				LOG(L_INFO,"ERROR: bad header  field\n");				goto  error;			case HDR_EOH:				msg->eoh=tmp; /* or rest?*/				msg->parsed_flag|=HDR_EOH;				pkg_free(hf);				goto skip;			case HDR_OTHER: /*do nothing*/				break;			case HDR_CALLID:				if (msg->callid==0) msg->callid=hf;				msg->parsed_flag|=HDR_CALLID;				break;			case HDR_TO:				if (msg->to==0) msg->to=hf;				msg->parsed_flag|=HDR_TO;				break;			case HDR_CSEQ:				if (msg->cseq==0) msg->cseq=hf;				msg->parsed_flag|=HDR_CSEQ;				break;			case HDR_FROM:				if (msg->from==0) msg->from=hf;				msg->parsed_flag|=HDR_FROM;				break;			case HDR_CONTACT:				if (msg->contact==0) msg->contact=hf;				msg->parsed_flag|=HDR_CONTACT;				break;			case HDR_MAXFORWARDS:				if(msg->maxforwards==0) msg->maxforwards=hf;				msg->parsed_flag|=HDR_MAXFORWARDS;				break;			case HDR_ROUTE:				if (msg->route==0) msg->route=hf;				msg->parsed_flag|=HDR_ROUTE;				break;			case HDR_RECORDROUTE:				if (msg->record_route==0) msg->record_route = hf;				msg->parsed_flag|=HDR_RECORDROUTE;				break;			case HDR_CONTENTTYPE:				if (msg->content_type==0) msg->content_type = hf;				msg->parsed_flag|=HDR_CONTENTTYPE;				break;			case HDR_CONTENTLENGTH:				if (msg->content_length==0) msg->content_length = hf;				msg->parsed_flag|=HDR_CONTENTLENGTH;				break;		        case HDR_AUTHORIZATION:			        if (msg->authorization==0) msg->authorization = hf;				msg->parsed_flag|=HDR_AUTHORIZATION;				break;        		case HDR_EXPIRES:				if (msg->expires==0) msg->expires = hf;				msg->parsed_flag|=HDR_EXPIRES;				break;		        case HDR_PROXYAUTH:				if (msg->proxy_auth==0) msg->proxy_auth = hf;				msg->parsed_flag|=HDR_PROXYAUTH;				break;		        case HDR_WWWAUTH:				if (msg->www_auth==0) msg->www_auth = hf;				msg->parsed_flag|=HDR_WWWAUTH;				break;		        case HDR_SUPPORTED:				if (msg->supported==0) msg->supported = hf;				msg->parsed_flag|=HDR_SUPPORTED;				break;		        case HDR_REQUIRE:				if (msg->require==0) msg->require = hf;				msg->parsed_flag|=HDR_REQUIRE;				break;		        case HDR_PROXYREQUIRE:				if (msg->proxy_require==0) msg->proxy_require = hf;				msg->parsed_flag|=HDR_PROXYREQUIRE;				break;		        case HDR_UNSUPPORTED:				if (msg->unsupported==0) msg->unsupported=hf;				msg->parsed_flag|=HDR_UNSUPPORTED;				break;		        case HDR_ALLOW:				if (msg->allow==0) msg->allow = hf;				msg->parsed_flag|=HDR_ALLOW;				break;			case HDR_EVENT:				if (msg->allow==0) msg->event = hf;				msg->parsed_flag|=HDR_EVENT;				break;			case HDR_VIA:				msg->parsed_flag|=HDR_VIA;				DBG("parse_headers: Via found, flags=%d\n", flags);				if (msg->via1==0) {					DBG("parse_headers: this is the first via\n");					msg->h_via1=hf;					msg->via1=hf->parsed;					if (msg->via1->next){						msg->via2=msg->via1->next;						msg->parsed_flag|=HDR_VIA2;					}				}else if (msg->via2==0){					msg->h_via2=hf;					msg->via2=hf->parsed;					msg->parsed_flag|=HDR_VIA2;					DBG("parse_headers: this is the second via\n");				}				break;			default:				LOG(L_CRIT, "BUG: parse_headers: unknown header type %d\n",							hf->type);				goto error;		}		/* add the header to the list*/		if (msg->last_header==0){			msg->headers=hf;			msg->last_header=hf;		}else{			msg->last_header->next=hf;			msg->last_header=hf;		}#ifdef EXTRA_DEBUG		DBG("header field type %d, name=<%s>, body=<%s>\n",			hf->type, hf->name.s, hf->body.s);#endif		tmp=rest;	}skip:	msg->unparsed=tmp;	return 0;error:	ser_error=E_BAD_REQ;	if (hf) pkg_free(hf);	if (next) msg->parsed_flag |= orig_flag;	return -1;}