fix: leak
This commit is contained in:
5
file.c
5
file.c
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user