--- parse822.c.orig Tue Mar 13 20:55:12 2001 +++ parse822.c Tue Mar 13 23:02:30 2001 @@ -71,7 +71,7 @@ int StrAppendN(char** to, char* from, si if(!new) { return 0; } - + *to = new; } else { *to = (char*) malloc(n + 1); @@ -251,7 +251,7 @@ int GetComment(char** p, char* e, char** if(!GetSpecial(p, e, '(')) { return 0; } - + while(*p != e) { char c = **p; @@ -398,6 +398,7 @@ int GetPhrase(char** p, char* e, char** StrAppend(phrase, word); *word = 0; } + StrFree (&word); } return 1; } @@ -439,7 +440,7 @@ int address_create0 (address_t* a, const if(!a || *a) { return EINVAL; } - + status = GetAddressList(a, (char*) s); if(status > 0) { @@ -469,7 +470,7 @@ int GetAddressList(mailbox_t** a, char* /* An address can contain a group, so an entire * list of addresses may have been appended, or no - * addresses at all. Walk to the end. + * addresses at all. Walk to the end. */ while(*an) { ++ok; @@ -529,7 +530,7 @@ int GetGroup(char**p, char* e, mailbox_t /* see if there are more */ SkipComments(p, e); - + while(GetSpecial(p, e, ',')) { SkipComments(p, e); @@ -579,6 +580,7 @@ int GetMailBox(char** p, char* e, mailbo if(!GetRouteAddr(p, e, a)) { *p = save; + StrFree (&phrase); return 0; } @@ -622,7 +624,7 @@ int GetRouteAddr(char** p, char* e, mail *p = save; address_destroy(a); - + return 0; } @@ -632,7 +634,7 @@ int GetRouteAddr(char** p, char* e, mail int GetRoute(char** p, char* e, char** route) { // route = 1#("@" domain ) ":" - // + // // Note: I don't hav a way of returning the route, so toss it for now. char* accumulator = 0; @@ -642,6 +644,7 @@ int GetRoute(char** p, char* e, char** r if(!GetSpecial(p, e, '@')) { // it's not a route + StrFree(&accumulator); return 0; } @@ -651,6 +654,7 @@ int GetRoute(char** p, char* e, char** r if(!GetDomain(p, e, &accumulator)) { // it looked like a route, but there's no domain! + StrFree(&accumulator); return 0; } @@ -666,6 +670,7 @@ int GetRoute(char** p, char* e, char** r SkipComments(p, e); if(!GetSpecial(p, e, ':')) { + StrFree(&accumulator); return 0; } @@ -682,18 +687,25 @@ int GetAddrSpec(char** p, char* e, mailb char* local_part = 0; char* domain = 0; - if(!GetLocalPart(p, e, &local_part)) - return 0; + if(!GetLocalPart(p, e, &local_part)) { + StrFree (&local_part); + StrFree (&domain); + return 0; + } SkipComments(p, e); if(!GetSpecial(p, e, '@')) { *p = save; + StrFree (&local_part); + StrFree (&domain); return 0; } if(!GetDomain(p, e, &domain)) { *p = save; + StrFree (&local_part); + StrFree (&domain); return 0; } @@ -730,6 +742,7 @@ int GetLocalPart(char** p, char* e, char if(!GetLocalPart(p, e, &more)) { *p = save; + StrFree(&more); return 1; } // append more @@ -768,6 +781,7 @@ int GetDomain(char** p, char* e, char** char* more = 0; if(!GetDomain(p, e, &more)) { *p = save; + StrFree(&more); return 1; } @@ -835,6 +849,7 @@ int GetDomainLiteral(char** p, char* e, if(!GetSpecial(p, e, ']')) { *p = save; + StrFree(&literal); return 0; } StrAppendChar(&literal, ']');