1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-23 21:10:29 +02:00

(scm_gethostname): Preserve errno across free() call.

This commit is contained in:
Kevin Ryde 2004-03-19 23:58:22 +00:00
parent 41f8545d08
commit 3c0a41b108

View file

@ -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);