(krb5_config_parse_file_debug): make sure of closing the file on error

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8947 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
2000-08-16 07:40:36 +00:00
parent dcac4bde92
commit 8f93d0ede7

View File

@@ -210,7 +210,7 @@ krb5_config_parse_file_debug (const char *fname,
krb5_config_section *s; krb5_config_section *s;
krb5_config_binding *b; krb5_config_binding *b;
char buf[BUFSIZ]; char buf[BUFSIZ];
int ret; int ret = 0;
s = NULL; s = NULL;
b = NULL; b = NULL;
@@ -218,7 +218,7 @@ krb5_config_parse_file_debug (const char *fname,
f = fopen (fname, "r"); f = fopen (fname, "r");
if (f == NULL) { if (f == NULL) {
*error_message = "cannot open file"; *error_message = "cannot open file";
return -1; return ENOENT;
} }
*res = NULL; *res = NULL;
while (fgets(buf, sizeof(buf), f) != NULL) { while (fgets(buf, sizeof(buf), f) != NULL) {
@@ -234,20 +234,23 @@ krb5_config_parse_file_debug (const char *fname,
continue; continue;
if (*p == '[') { if (*p == '[') {
ret = parse_section(p, &s, res, error_message); ret = parse_section(p, &s, res, error_message);
if (ret) if (ret) {
return ret; goto out;
}
b = NULL; b = NULL;
} else if (*p == '}') { } else if (*p == '}') {
*error_message = "unmatched }"; *error_message = "unmatched }";
return -1; ret = -1;
goto out;
} else if(*p != '\0') { } else if(*p != '\0') {
ret = parse_binding(f, lineno, p, &b, &s->u.list, error_message); ret = parse_binding(f, lineno, p, &b, &s->u.list, error_message);
if (ret) if (ret)
return ret; goto out;
} }
} }
out:
fclose (f); fclose (f);
return 0; return ret;
} }
krb5_error_code krb5_error_code