diff options
| author | Bernard Xiong <[email protected]> | 2021-03-17 17:57:22 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-03-17 17:57:22 +0800 |
| commit | 6a80bcef1fdde8f85e4f1b314b91fe20a91076d4 (patch) | |
| tree | ef5b7e6c82d076f5aca5aad2f144d1b85178d60c /components | |
| parent | 95c0569b332fe659269706625435c4f1f7001142 (diff) | |
| parent | c40fd2da7097c80b3013966b358a5ecb21ccbcbd (diff) | |
Merge pull request #4473 from mysterywolf/AT
[at][bug] 修复内存泄漏的bug
Diffstat (limited to 'components')
| -rw-r--r-- | components/net/at/src/at_client.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/components/net/at/src/at_client.c b/components/net/at/src/at_client.c index 5e077512ae..a613ea1435 100644 --- a/components/net/at/src/at_client.c +++ b/components/net/at/src/at_client.c @@ -8,6 +8,7 @@ * 2018-03-30 chenyong first version * 2018-04-12 chenyong add client implement * 2018-08-17 chenyong multiple client support + * 2021-03-17 Meco Man fix a buf of leaking memory */ #include <at.h> @@ -104,18 +105,23 @@ void at_delete_resp(at_response_t resp) */ at_response_t at_resp_set_info(at_response_t resp, rt_size_t buf_size, rt_size_t line_num, rt_int32_t timeout) { + char *p_temp; RT_ASSERT(resp); if (resp->buf_size != buf_size) { resp->buf_size = buf_size; - resp->buf = (char *) rt_realloc(resp->buf, buf_size); - if (!resp->buf) + p_temp = (char *) rt_realloc(resp->buf, buf_size); + if (p_temp == RT_NULL) { LOG_D("No memory for realloc response buffer size(%d).", buf_size); return RT_NULL; } + else + { + resp->buf = p_temp; + } } resp->line_num = line_num; |
