Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HUST CSE]Modify the null pointer fifo to access first and then judge #368

Merged
merged 1 commit into from
Apr 23, 2023

Conversation

Eric-hust
Copy link
Contributor

@Eric-hust Eric-hust commented Apr 23, 2023

1.为什么提交这份PR (why to submit this PR)
在/components/connectivity/mqttclient/common/log/fifo.c这个文件中,第101行

salof_sem_pend(fifo->sem, timeout);

if((!fifo) || (!buff) || (!len))
    return 0;

这处代码首先进行salof_sem_pend(fifo->sem, timeout)再进行判断fifo是否为空有问题,如果fifo为空,则访问其成员变量会导致未定义的行为。

2.你的解决方案是什么 (what is your solution)
应该先检查传入的salof_fifo_t类型的参数fifo是否为空(即是否为NULL),然后才能使用它的成员变量。因此,应该将if((!fifo) || (!buff) || (!len))这个语句的判断移到salof_sem_pend(fifo->sem, timeout)之前。

3.在什么测试环境下测试通过 (what is the test environment)
all

@tencent-adm
Copy link

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Eric-hust Eric-hust marked this pull request as ready for review April 23, 2023 03:15
@Supowang1989 Supowang1989 merged commit 250ca3e into OpenAtomFoundation:master Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants