mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-23 13:00:34 +02:00
(scm_gethostname): Preserve errno across free() call.
This commit is contained in:
parent
41f8545d08
commit
3c0a41b108
1 changed files with 3 additions and 1 deletions
|
@ -1611,7 +1611,7 @@ SCM_DEFINE (scm_gethostname, "gethostname", 0, 0, 0,
|
||||||
{
|
{
|
||||||
/* 256 is for Solaris, under Linux ENAMETOOLONG is returned if not
|
/* 256 is for Solaris, under Linux ENAMETOOLONG is returned if not
|
||||||
large enough. */
|
large enough. */
|
||||||
int len = 256, res;
|
int len = 256, res, save_errno;
|
||||||
char *p = scm_must_malloc (len, "gethostname");
|
char *p = scm_must_malloc (len, "gethostname");
|
||||||
SCM name;
|
SCM name;
|
||||||
|
|
||||||
|
@ -1624,7 +1624,9 @@ SCM_DEFINE (scm_gethostname, "gethostname", 0, 0, 0,
|
||||||
}
|
}
|
||||||
if (res == -1)
|
if (res == -1)
|
||||||
{
|
{
|
||||||
|
save_errno = errno;
|
||||||
scm_must_free (p);
|
scm_must_free (p);
|
||||||
|
errno = save_errno;
|
||||||
SCM_SYSERROR;
|
SCM_SYSERROR;
|
||||||
}
|
}
|
||||||
name = scm_makfrom0str (p);
|
name = scm_makfrom0str (p);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue