Commit ec45d0d2 authored by Rusty Russell's avatar Rusty Russell

Preserve errno on talloc_free

parent 4f2616ac
......@@ -730,7 +730,11 @@ void *talloc_named_const(const void *context, size_t size, const char *name)
*/
int talloc_free(void *ptr)
{
return _talloc_free(ptr);
int saved_errno = errno, ret;
ret = _talloc_free(ptr);
if (ret == 0)
errno = saved_errno;
return ret;
}
......
......@@ -100,6 +100,7 @@
* returned for success and -1 for failure. The only possible failure condition
* is if the pointer had a destructor attached to it and the destructor
* returned -1. See talloc_set_destructor() for details on destructors.
* errno will be preserved unless the talloc_free fails.
*
* If this pointer has an additional parent when talloc_free() is called then
* the memory is not actually released, but instead the most recently
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment