[AT] Add null pointer check in at_client_get (#7154)
1. prevent null-pointer dereference in rt_strcmp
This commit is contained in:
parent
dd17ca01e6
commit
3a9c5690b1
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
* Copyright (c) 2006-2023, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -610,7 +610,8 @@ at_client_t at_client_get(const char *dev_name)
|
||||||
|
|
||||||
for (idx = 0; idx < AT_CLIENT_NUM_MAX; idx++)
|
for (idx = 0; idx < AT_CLIENT_NUM_MAX; idx++)
|
||||||
{
|
{
|
||||||
if (rt_strcmp(at_client_table[idx].device->parent.name, dev_name) == 0)
|
if (at_client_table[idx].device &&
|
||||||
|
(rt_strcmp(at_client_table[idx].device->parent.name, dev_name) == 0))
|
||||||
{
|
{
|
||||||
return &at_client_table[idx];
|
return &at_client_table[idx];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue