From 3a9c5690b1fd5067259de6541c2f072bb63a8a10 Mon Sep 17 00:00:00 2001 From: Lu_Reaper <43989619+dingiso@users.noreply.github.com> Date: Mon, 3 Apr 2023 23:04:40 +0800 Subject: [PATCH] [AT] Add null pointer check in at_client_get (#7154) 1. prevent null-pointer dereference in rt_strcmp --- components/net/at/src/at_client.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/net/at/src/at_client.c b/components/net/at/src/at_client.c index 4eb2c055ba..de4c8a408e 100644 --- a/components/net/at/src/at_client.c +++ b/components/net/at/src/at_client.c @@ -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 * @@ -610,7 +610,8 @@ at_client_t at_client_get(const char *dev_name) 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]; }