fix: leak

This commit is contained in:
jonathan santis
2025-05-14 14:47:33 +02:00
parent 137f91de73
commit 9225740cd4
3 changed files with 27 additions and 9 deletions

12
test.c
View File

@@ -13,13 +13,16 @@ int main(void)
name = malloc(MAX_LEN_SECTIONNAME*sizeof(char));
getStrAtPos(teststr, 11, 15, &name, MAX_LEN_SECTIONNAME);
sectionName = malloc(MAX_LEN_SECTIONNAME*sizeof(char));
if((ret=checkSection(teststr,'[',']', &sectionName)) == FOUND_SECTION)
sectionName = malloc(MAX_LEN_SECTIONNAME);
memset(sectionName,0,MAX_LEN_SECTIONNAME);
ret=checkSection(teststr,'[',']', &sectionName);
if(ret == FOUND_SECTION)
{
printf("checkSection sucessfull\nsectionName=%s\n",sectionName);
}
else
{
free(sectionName);
printf("an error occured:%d\n",ret);
}
@@ -30,6 +33,8 @@ int main(void)
keyName = malloc(MAX_LEN_SECTIONNAME);
keyValue = malloc(MAX_LEN_SECTIONNAME);
memset(keyName,0,MAX_LEN_SECTIONNAME);
memset(keyValue,0,MAX_LEN_SECTIONNAME);
if((ret=getNameValuePair(testpair,
'=',0,
@@ -48,6 +53,7 @@ int main(void)
}
else {
printf("Error on getFile:%d\n",ret);
return 1;
}
content = malloc(neededSize);
if((ret=getFile("config.cfg",&content,neededSize,&neededSize))==NO_ERROR)
@@ -56,6 +62,8 @@ int main(void)
}
else {
printf("Error on getFile:%d\n",ret);
free(content);
return 1;
}
struct configEntry *entry=NULL;
int returnedCount=0;