fix: leak
This commit is contained in:
12
test.c
12
test.c
@@ -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,'[',']', §ionName)) == FOUND_SECTION)
|
||||
sectionName = malloc(MAX_LEN_SECTIONNAME);
|
||||
memset(sectionName,0,MAX_LEN_SECTIONNAME);
|
||||
ret=checkSection(teststr,'[',']', §ionName);
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user