mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-25 07:49:18 +00:00
libvmm: explicitly save and restore errno in vm_open()
In commit6bb140e3ca
, vm_destroy() was replaced with free() to preserve errno. However, it's possible that free() may change the errno as well. Keep the free() call, but explicitly save and restore errno. Noted by: jhb Fixes:6bb140e3ca
This commit is contained in:
parent
b2ae176d91
commit
a7f81b488d
@ -118,6 +118,7 @@ struct vmctx *
|
||||
vm_open(const char *name)
|
||||
{
|
||||
struct vmctx *vm;
|
||||
int saved_errno;
|
||||
|
||||
vm = malloc(sizeof(struct vmctx) + strlen(name) + 1);
|
||||
assert(vm != NULL);
|
||||
@ -133,7 +134,9 @@ vm_open(const char *name)
|
||||
|
||||
return (vm);
|
||||
err:
|
||||
saved_errno = errno;
|
||||
free(vm);
|
||||
errno = saved_errno;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user