on't use freed memory; streamline parse error reporting

This commit is contained in:
Pierangelo Masarati 2006-01-21 10:41:41 +00:00
parent 2b0bccc74c
commit 42bf993798

View File

@ -147,18 +147,27 @@ parse_cr(
"%s: line %d: Content rule has no OID\n",
fname, lineno );
cr_usage();
return 1;
code = 1;
goto done;
}
code = cr_add( cr, 1, scr, &err );
if ( code ) {
fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
fname, lineno, scherr2str( code ), err );
return 1;
code = 1;
goto done;
}
done:;
if ( code ) {
ldap_contentrule_free( cr );
} else {
ldap_memfree( cr );
return 0;
}
return code;
}
int
@ -186,18 +195,27 @@ parse_oc(
"%s: line %d: objectclass has no OID\n",
fname, lineno );
oc_usage();
return 1;
code = 1;
goto done;
}
code = oc_add( oc, 1, soc, &err );
if ( code ) {
fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
fname, lineno, scherr2str( code ), err );
return 1;
code = 1;
goto done;
}
done:;
if ( code ) {
ldap_objectclass_free( oc );
} else {
ldap_memfree( oc );
return 0;
}
return code;
}
static void
@ -268,23 +286,33 @@ parse_at(
"%s: line %d: attributeType has no OID\n",
fname, lineno );
at_usage();
return 1;
code = 1;
goto done;
}
/* operational attributes should be defined internally */
if ( at->at_usage ) {
fprintf( stderr, "%s: line %d: attribute type \"%s\" is operational\n",
fname, lineno, at->at_oid );
return 1;
code = 1;
goto done;
}
code = at_add( at, 1, sat, &err);
if ( code ) {
ldap_attributetype_free( at );
fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
fname, lineno, scherr2str(code), err);
return 1;
code = 1;
goto done;
}
done:;
if ( code ) {
ldap_attributetype_free( at );
} else {
ldap_memfree( at );
return 0;
}
return code;
}