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

5
file.c
View File

@@ -27,14 +27,14 @@ int getFile(char *fname, char **strContent,int cbSize,long *neededSize)
file_size = ftell(hfile);
if(strContent == NULL) //we must determine the size and return to neededSize
{
*neededSize = file_size;
*neededSize = file_size+1;
fclose(hfile);
return NO_ERROR;
}
if(cbSize < file_size)
{
*neededSize = file_size;
*neededSize = file_size+1; //null terminator
fclose(hfile);
return FILE_ERROR_STRCONTENT_TO_SMALL;
}
@@ -48,6 +48,7 @@ int getFile(char *fname, char **strContent,int cbSize,long *neededSize)
fclose(hfile);
return FILE_ERROR_READ_MISMATCH;
}
strContent[*neededSize]='\0';
fclose(hfile);
return NO_ERROR;
}