[AT] Add null pointer check in at_client_get (#7154)

1. prevent null-pointer dereference in rt_strcmp
This commit is contained in:
Lu_Reaper 2023-04-03 23:04:40 +08:00 committed by GitHub
parent dd17ca01e6
commit 3a9c5690b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -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];
} }