atc icon indicating copy to clipboard operation
atc copied to clipboard

Memory leakage problem in atc.c file

Open ogulcan90 opened this issue 4 years ago • 4 comments

Hi Nima,

In your atc.c file, atc_addSearch() function you are allocation memory as follows:

atc->search[atc->searchIndex] = (char*) atc_alloc(strlen(str) + 1);

However, you do not free the memory afterwards, thus, I believe this creates a memory leak, which leads a crush after some time. I'm using you gsm_v5 library that uses this library, so this problem affects it.

To solve this, I think you can put the following just before the "return true" atc_free(atc->search[atc->searchIndex]);

Regards, Ogulcan

ogulcan90 avatar Oct 06 '21 07:10 ogulcan90

Hello please increase it in config file

nimaltd avatar Oct 06 '21 09:10 nimaltd

It doesn't matter. An allocated memory has to be freed in order not to have a memory leakage. This is a rule.

Am I missing something?

ogulcan90 avatar Oct 06 '21 10:10 ogulcan90

this function for always search in your program. like some at-commands for ring and get new message. you don't need to delete it.

nimaltd avatar Oct 09 '21 07:10 nimaltd