mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 14:00:21 +02:00
* posix.c (scm_gethostname): Preserve errno across free() call.
This commit is contained in:
parent
726f82e747
commit
228651245d
1 changed files with 3 additions and 1 deletions
|
@ -1748,7 +1748,7 @@ SCM_DEFINE (scm_gethostname, "gethostname", 0, 0, 0,
|
|||
{
|
||||
/* 256 is for Solaris, under Linux ENAMETOOLONG is returned if not
|
||||
large enough. */
|
||||
int len = 256, res;
|
||||
int len = 256, res, save_errno;
|
||||
char *p = scm_malloc (len);
|
||||
SCM name;
|
||||
|
||||
|
@ -1761,7 +1761,9 @@ SCM_DEFINE (scm_gethostname, "gethostname", 0, 0, 0,
|
|||
}
|
||||
if (res == -1)
|
||||
{
|
||||
save_errno = errno;
|
||||
free (p);
|
||||
errno = save_errno;
|
||||
SCM_SYSERROR;
|
||||
}
|
||||
name = scm_makfrom0str (p);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue