提交 431c9e9d 编写于 作者: O openharmony_ci 提交者: Gitee

!678 signal内存泄露修复挑单到3.0tls

Merge pull request !678 from lnlan/tlsSignalFixed
...@@ -71,37 +71,44 @@ STATIC VOID OsMoveTmpInfoToUnbInfo(sig_cb *sigcb, INT32 signo) ...@@ -71,37 +71,44 @@ STATIC VOID OsMoveTmpInfoToUnbInfo(sig_cb *sigcb, INT32 signo)
{ {
SigInfoListNode *tmpInfoNode = sigcb->tmpInfoListHead; SigInfoListNode *tmpInfoNode = sigcb->tmpInfoListHead;
SigInfoListNode **prevHook = &sigcb->tmpInfoListHead; SigInfoListNode **prevHook = &sigcb->tmpInfoListHead;
INT32 isFirstDel = 1;
while (tmpInfoNode != NULL) { while (tmpInfoNode != NULL) {
if (tmpInfoNode->info.si_signo == signo) { if (tmpInfoNode->info.si_signo == signo) {
/* In some case, many siginfos have same signo, only last one inserted list need copy to unbinfo. */
if (isFirstDel) {
/* copy tmpinfo to unbinfo. */ /* copy tmpinfo to unbinfo. */
(VOID)memcpy_s(&sigcb->sigunbinfo, sizeof(siginfo_t), &tmpInfoNode->info, sizeof(siginfo_t)); (VOID)memcpy_s(&sigcb->sigunbinfo, sizeof(siginfo_t), &tmpInfoNode->info, sizeof(siginfo_t));
isFirstDel = 0;
}
/* delete tmpinfo from tmpList. */ /* delete tmpinfo from tmpList. */
*prevHook = tmpInfoNode->next; *prevHook = tmpInfoNode->next;
(VOID)LOS_MemFree(m_aucSysMem0, tmpInfoNode); (VOID)LOS_MemFree(m_aucSysMem0, tmpInfoNode);
tmpInfoNode = *prevHook; tmpInfoNode = *prevHook;
continue; break;
} }
prevHook = &tmpInfoNode->next; prevHook = &tmpInfoNode->next;
tmpInfoNode = tmpInfoNode->next; tmpInfoNode = tmpInfoNode->next;
} }
return;
} }
STATIC INT32 OsAddSigInfoToTmpList(sig_cb *sigcb, siginfo_t *info) STATIC INT32 OsAddSigInfoToTmpList(sig_cb *sigcb, siginfo_t *info)
{ {
SigInfoListNode *tmp = (SigInfoListNode *)LOS_MemAlloc(m_aucSysMem0, sizeof(SigInfoListNode)); /* try to find the old siginfo */
SigInfoListNode *tmp = sigcb->tmpInfoListHead;
while (tmp != NULL) {
if (tmp->info.si_signo == info->si_signo) {
/* found it, break. */
break;
}
tmp = tmp->next;
}
if (tmp == NULL) {
/* none, alloc new one */
tmp = (SigInfoListNode *)LOS_MemAlloc(m_aucSysMem0, sizeof(SigInfoListNode));
if (tmp == NULL) { if (tmp == NULL) {
return LOS_NOK; return LOS_NOK;
} }
(VOID)memcpy_s(&tmp->info, sizeof(siginfo_t), info, sizeof(siginfo_t));
tmp->next = sigcb->tmpInfoListHead; tmp->next = sigcb->tmpInfoListHead;
sigcb->tmpInfoListHead = tmp; sigcb->tmpInfoListHead = tmp;
}
(VOID)memcpy_s(&tmp->info, sizeof(siginfo_t), info, sizeof(siginfo_t));
return LOS_OK; return LOS_OK;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册