Fix: handle file opening errors
This commit is contained in:
parent
2a6bb4354e
commit
21d351c7e2
2 changed files with 1 additions and 2 deletions
|
@ -4,7 +4,6 @@ bool open_file(const char* path, FILE** file, struct stat* file_stat) {
|
||||||
(*file) = fopen(path, "r");
|
(*file) = fopen(path, "r");
|
||||||
if ((*file) == NULL) {
|
if ((*file) == NULL) {
|
||||||
printf("Fopen error: %d\n", errno);
|
printf("Fopen error: %d\n", errno);
|
||||||
fclose((*file));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ void md2_hash_2(size_t len, const uint8_t buf[len], uint8_t out[16]) {
|
||||||
FILE* file;
|
FILE* file;
|
||||||
struct stat file_stat;
|
struct stat file_stat;
|
||||||
if (!open_file((char*)buf, &file, &file_stat)) {
|
if (!open_file((char*)buf, &file, &file_stat)) {
|
||||||
fprintf(stderr, "Error opening the file!");
|
fprintf(stderr, "Error opening the file!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue