Don't clobber errno during error cleanup in krb5_storage_from_fd().
This commit is contained in:
@@ -89,6 +89,7 @@ KRB5_LIB_FUNCTION krb5_storage * KRB5_LIB_CALL
|
|||||||
krb5_storage_from_fd(krb5_socket_t fd_in)
|
krb5_storage_from_fd(krb5_socket_t fd_in)
|
||||||
{
|
{
|
||||||
krb5_storage *sp;
|
krb5_storage *sp;
|
||||||
|
int saved_errno;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
#ifdef SOCKET_IS_NOT_AN_FD
|
#ifdef SOCKET_IS_NOT_AN_FD
|
||||||
@@ -108,16 +109,22 @@ krb5_storage_from_fd(krb5_socket_t fd_in)
|
|||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
errno = ENOMEM;
|
||||||
sp = malloc(sizeof(krb5_storage));
|
sp = malloc(sizeof(krb5_storage));
|
||||||
if (sp == NULL) {
|
if (sp == NULL) {
|
||||||
|
saved_errno = errno;
|
||||||
close(fd);
|
close(fd);
|
||||||
|
errno = saved_errno;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errno = ENOMEM;
|
||||||
sp->data = malloc(sizeof(fd_storage));
|
sp->data = malloc(sizeof(fd_storage));
|
||||||
if (sp->data == NULL) {
|
if (sp->data == NULL) {
|
||||||
|
saved_errno = errno;
|
||||||
close(fd);
|
close(fd);
|
||||||
free(sp);
|
free(sp);
|
||||||
|
errno = saved_errno;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
sp->flags = 0;
|
sp->flags = 0;
|
||||||
|
Reference in New Issue
Block a user