Avoid using free memory, found by IBM checker.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16946 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -155,19 +155,20 @@ write_v4_cc(krb5_context context, const char *tkfile,
|
|||||||
|
|
||||||
fd = open(path, O_WRONLY|O_CREAT, 0600);
|
fd = open(path, O_WRONLY|O_CREAT, 0600);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
free(path);
|
ret = errno;
|
||||||
krb5_set_error_string(context,
|
krb5_set_error_string(context,
|
||||||
"krb5_krb_tf_setup: error opening file %s",
|
"krb5_krb_tf_setup: error opening file %s",
|
||||||
path);
|
path);
|
||||||
return errno;
|
free(path);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fstat(fd, &sb) != 0 || !S_ISREG(sb.st_mode)) {
|
if (fstat(fd, &sb) != 0 || !S_ISREG(sb.st_mode)) {
|
||||||
free(path);
|
|
||||||
close(fd);
|
|
||||||
krb5_set_error_string(context,
|
krb5_set_error_string(context,
|
||||||
"krb5_krb_tf_setup: tktfile %s is not a file",
|
"krb5_krb_tf_setup: tktfile %s is not a file",
|
||||||
path);
|
path);
|
||||||
|
free(path);
|
||||||
|
close(fd);
|
||||||
return KRB5_FCC_PERM;
|
return KRB5_FCC_PERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,11 +179,11 @@ write_v4_cc(krb5_context context, const char *tkfile,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i == KRB5_TF_LCK_RETRY_COUNT) {
|
if (i == KRB5_TF_LCK_RETRY_COUNT) {
|
||||||
free(path);
|
|
||||||
close(fd);
|
|
||||||
krb5_set_error_string(context,
|
krb5_set_error_string(context,
|
||||||
"krb5_krb_tf_setup: failed to lock %s",
|
"krb5_krb_tf_setup: failed to lock %s",
|
||||||
path);
|
path);
|
||||||
|
free(path);
|
||||||
|
close(fd);
|
||||||
return KRB5_FCC_PERM;
|
return KRB5_FCC_PERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,11 +191,11 @@ write_v4_cc(krb5_context context, const char *tkfile,
|
|||||||
ret = ftruncate(fd, 0);
|
ret = ftruncate(fd, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
flock(fd, LOCK_UN);
|
flock(fd, LOCK_UN);
|
||||||
free(path);
|
|
||||||
close(fd);
|
|
||||||
krb5_set_error_string(context,
|
krb5_set_error_string(context,
|
||||||
"krb5_krb_tf_setup: failed to truncate %s",
|
"krb5_krb_tf_setup: failed to truncate %s",
|
||||||
path);
|
path);
|
||||||
|
free(path);
|
||||||
|
close(fd);
|
||||||
return KRB5_FCC_PERM;
|
return KRB5_FCC_PERM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user