Fix: valgrind warnings
This commit is contained in:
parent
859be7d54e
commit
bb51675a94
1 changed files with 3 additions and 2 deletions
|
@ -35,12 +35,13 @@ uint8_t* read_file(const char* path, size_t* size) {
|
||||||
|
|
||||||
struct sysinfo info;
|
struct sysinfo info;
|
||||||
int r = sysinfo(&info);
|
int r = sysinfo(&info);
|
||||||
if (r != 0 || info.freeram < (unsigned long)statOfFile.st_size * 2) {
|
if (r != 0 || info.freeram < (unsigned long)(statOfFile.st_blksize *
|
||||||
|
statOfFile.st_blocks * 2)) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* data = malloc(statOfFile.st_size);
|
uint8_t* data = malloc(statOfFile.st_blksize * statOfFile.st_blocks);
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in a new issue