提交 3c4a5536 编写于 作者: R root

fix: posix用例存在mutex资源泄露

方案描述:
1, 对posix中使用锁之后,增加对锁的释放

fix #I64Y7G
Signed-off-by: Nwangchen <wangchen240@huawei.com>
上级 7d3f2920
......@@ -37,6 +37,7 @@ int vsnprintf(char *restrict s, size_t n, const char *restrict fmt, va_list ap)
{
unsigned char buf[1];
char dummy[1];
int ret;
struct cookie c = { .s = n ? s : dummy, .n = n ? n-1 : 0 };
pthread_mutex_t locallock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
FILE f = {
......@@ -53,5 +54,7 @@ int vsnprintf(char *restrict s, size_t n, const char *restrict fmt, va_list ap)
}
*c.s = 0;
return vfprintf(&f, fmt, ap);
ret = vfprintf(&f, fmt, ap);
pthread_mutex_destroy(&locallock);
return ret;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册