try not to leak memory in case of parse error

This commit is contained in:
leitner
2002-07-16 23:00:26 +00:00
parent d406931b14
commit 7b68d29ade
10 changed files with 82 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ int scan_ldapmodifyrequest(const char* src,const char* max,struct ModifyRequest*
int res,tmp;
long oslen; /* outer sequence length */
struct Modification* last=0;
m->m.next=0;
if (!(res=scan_ldapstring(src,max,&m->object))) goto error;
if (!(tmp=scan_asn1SEQUENCE(src+res,max,&oslen))) goto error;
res+=tmp;
@@ -73,5 +74,19 @@ int scan_ldapmodifyrequest(const char* src,const char* max,struct ModifyRequest*
} while (src+res<max);
return res;
error:
free_ldapmodifyrequest(m);
return 0;
}
static void free_mod(struct Modification* m) {
while (m) {
struct Modification* tmp=m->next;
free(m);
m=tmp;
}
}
void free_ldapmodifyrequest(struct ModifyRequest* m) {
free_ldapadl(m->m.vals.next);
free_mod(m->m.next);
}